datetime conversion of posix and datenum array timezone difference
3 次查看(过去 30 天)
显示 更早的评论
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 个评论
采纳的回答
Walter Roberson
2020-10-9
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Dates and Time 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!