Convert Datetime to UTC
조회 수: 143 (최근 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!