Convert Datetime to UTC
128 次查看(过去 30 天)
显示 更早的评论
How to convert datetime('today') into utc format. Preferably [YYYY MM DD 12 0 0].
0 个评论
采纳的回答
Star Strider
2020-6-24
Try this:
T = datetime('now', 'Format','yyyy MM dd HH mm ss', 'TimeZone','local') % Local Time Zone
T.TimeZone = 'Z' % Convert To UTC
producing:
T =
datetime
2020 06 23 18 19 09
T =
datetime
2020 06 24 00 19 09
.
3 个评论
Star Strider
2020-6-24
My pleasure!
I thought that was just a formatting example.
I’m still not certain what you want.
Try this:
T = datetime('now', 'Format','yyyy MM dd 12 0 0', 'TimeZone','local') % Local Time Zone
T.TimeZone = 'Z' % Convert To UTC
Walter Roberson
2020-6-24
dateshift to start of hour or day.
If you need "noon" then dateshift to start of day and then add hours(12)
更多回答(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!