How to convert Universal time to Local time?
40 ビュー (過去 30 日間)
古いコメントを表示
Dear All,
I am trying to convert Universal time to local time. I used this function
% Convert time values to datetime array
timeDatetime = datetime(selectedData(:,3)./3600, 'ConvertFrom', 'epochtime', 'Epoch', '1970-01-01');
% Apply time zone offset to datetime array
timeLocal = tzoffset(timeDatetime, 'EST','5');
but I got an error " Too Many input arguments".
Does anyone knows how to resoolve it?
Thank you,
Ara
4 件のコメント
Steven Lord
2022 年 12 月 27 日
dt = datetime('now', 'TimeZone', 'local')
dt.TimeZone
dt.TimeZone = 'America/New_York'
dt.TimeZone = 'local'
採用された回答
Jan
2022 年 12 月 26 日
編集済み: Jan
2022 年 12 月 26 日
[dt,dst] = tzoffset(t)
Therefore the additional arguments 'EST','5' are not valid.
Maybe you mean
T = datetime(selectedData(:,3)./3600, ...
'ConvertFrom', 'epochtime', 'Epoch', '1970-01-01', 'TimeZone', 'UTC');
T.TimeZone = 'America/New_York'; % Set accordingly, perhaps 'system'
3 件のコメント
Eric Sofen
2022 年 12 月 27 日
That looks like a problem with your conversion from epoch time, but without knowing the values of selectedData, it's hard to know what the appropriate conversion factor should be.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Calendar についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!