How to get UTC time in my program?
132 ビュー (過去 30 日間)
古いコメントを表示
Dear All,
I am wondering if it is pissible to get the UTC time in my program. Do I need the internet avaibale if I want to get UTC time?
Thanks a lot.
Benson
0 件のコメント
採用された回答
Star Strider
2020 年 7 月 12 日
Try this:
dtLCL = datetime('now', 'TimeZone','local') % Current Local Time
dtUTC = datetime(dtLCL, 'TimeZone','Z') % Current UTC Time
That will give you both the local time and the corresponding UTC time.
.
5 件のコメント
Charalambos Hadjipanayi
2023 年 2 月 1 日
This gives you a simple network time, which does not rely on local computer time:
url_time = webread('http://worldtimeapi.org/api/timezone/Etc/UTC')
その他の回答 (1 件)
Vini Lima
2022 年 3 月 25 日
utc_time = datetime('now', 'timezone', 'utc')
1 件のコメント
Charalambos Hadjipanayi
2023 年 2 月 1 日
This just converts your local computer time to UTC. So if your local computer time is incorrect for any reason, the utc_time will be also incorrect.
参考
カテゴリ
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!