datetime conversion of posix and datenum array timezone difference
3 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
giacomo labbri
il 9 Ott 2020
Risposto: Walter Roberson
il 9 Ott 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 Commenti
Risposta accettata
Walter Roberson
il 9 Ott 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 Commenti
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Dates and Time in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!