フィルターのクリア

datetime conversion of posix and datenum array timezone difference

2 ビュー (過去 30 日間)
giacomo labbri
giacomo labbri 2020 年 10 月 9 日
回答済み: Walter Roberson 2020 年 10 月 9 日
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

採用された回答

Walter Roberson
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 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by