Borrar filtros
Borrar filtros

How to convert specified time to GMT/UTC?

94 visualizaciones (últimos 30 días)
taimour sadiq
taimour sadiq el 18 de Oct. de 2023
Editada: Florian Bidaud el 18 de Oct. de 2023
i want to convert datetime({'18-Oct-2023 17:40:00' '18-Oct-2023 18:00:00'},'TimeZone','+05:00') to GMT or UTC?
required result below:
'18-Oct-2023 12:40:00' '18-Oct-2023 01:00:00'

Respuesta aceptada

Star Strider
Star Strider el 18 de Oct. de 2023
Editada: Star Strider el 18 de Oct. de 2023
Try this —
DT = datetime({'18-Oct-2023 17:40:00' '18-Oct-2023 18:00:00'},'TimeZone','+05:00')
DT = 1×2 datetime array
18-Oct-2023 17:40:00 18-Oct-2023 18:00:00
DT_UTC = DT;
DT_UTC.TimeZone = 'UTC' % Copnmvert To UTC
DT_UTC = 1×2 datetime array
18-Oct-2023 12:40:00 18-Oct-2023 13:00:00
DT_UTC.Format = 'dd-MMM-yyyy hh:mm:ss' % Convert To 12-Hour Time
DT_UTC = 1×2 datetime array
18-Oct-2023 12:40:00 18-Oct-2023 01:00:00
EDIT — Added 12-Hour time conversion
.

Más respuestas (1)

Florian Bidaud
Florian Bidaud el 18 de Oct. de 2023
Editada: Florian Bidaud el 18 de Oct. de 2023
https://uk.mathworks.com/help/matlab/ref/datetime.html#buhzxmk-1-TimeZone
date = datetime({'18-Oct-2023 17:40:00' '18-Oct-2023 18:00:00'},'TimeZone','+05:00')
date = 1×2 datetime array
18-Oct-2023 17:40:00 18-Oct-2023 18:00:00
datetime(date, 'TimeZone', 'UTC', 'Format', 'dd-MMMM-yyyy hh:mm:ss')
ans = 1×2 datetime array
18-October-2023 12:40:00 18-October-2023 01:00:00
datetime(date, 'TimeZone', 'Europe/London', 'Format', 'dd-MMMM-yyyy hh:mm:ss')
ans = 1×2 datetime array
18-October-2023 01:40:00 18-October-2023 02:00:00

Categorías

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

Etiquetas

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by