datetime conversion of posix and datenum array timezone difference
3 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
giacomo labbri
le 9 Oct 2020
Réponse apportée : Walter Roberson
le 9 Oct 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 commentaires
Réponse acceptée
Walter Roberson
le 9 Oct 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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Dates and Time dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!