datetime conversion of posix and datenum array timezone difference
3 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
giacomo labbri
am 9 Okt. 2020
Beantwortet: Walter Roberson
am 9 Okt. 2020
Hi,
I am converting into datetime arrays some arrays in posix time format (second since 1/1/1970 00:00:00) and in datenum format (days since the year 0/0/0000 00:00:00) using these lines
Given date1 a datenum array and date2 a posix array
date1_conv=datetime(data1, 'ConvertForm', 'datenum', 'TimeZone', 'America/Barbados')
date2_conv= datetime(data2, 'ConvertForm', 'posixtime', 'TimeZone', 'America/Barbados')
I have notice that if I change the TimeZone in the case of posixtime the output change. For example:
date2_conv= datetime(data2, 'ConvertForm', 'posixtime', 'TimeZone', 'UTC')
While the output does not change if I change the timezone in the case of datenum input. For example:
date1_conv= datetime(data1, 'ConvertForm', 'posixtime', 'TimeZone', 'UTC')
My question is why does this happen?
Thanks in advance,
Giacomo
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 9 Okt. 2020
Posix Time is defined relative to a particular timezone (in the POSIX standard), whereas datenum is not defined relative to any particular timezone.
That said... since POSIX Time is defined relative to UTC, one would expect that datetime would automatically tag on a timezone identifier when you converted from posixtime, but it does not do so in the datetime object.
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Dates and Time finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!