Convert Datetime to UTC

129 visualizaciones (últimos 30 días)
Nathan Jalal
Nathan Jalal el 23 de Jun. de 2020
Comentada: Walter Roberson el 24 de Jun. de 2020
How to convert datetime('today') into utc format. Preferably [YYYY MM DD 12 0 0].

Respuesta aceptada

Star Strider
Star Strider el 24 de Jun. de 2020
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 comentarios
Star Strider
Star Strider el 24 de Jun. de 2020
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
Walter Roberson el 24 de Jun. de 2020
dateshift to start of hour or day.
If you need "noon" then dateshift to start of day and then add hours(12)

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Dates and Time en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by