Problem in converting datetime to POSIX and then the same POSIX back to datetime

8 visualizaciones (últimos 30 días)
Given that I have specified the time zone in t, could you please explain why the last row will not convert it back to 'XXXX-XX-XX 10:05:24', but to 'XXXX-XX-XX 09:05:24'?
t = datetime('2016-07-29 10:05:24', 'TimeZone','Europe/London') + calmonths(1:3) %-> ZONED datetime
p = posixtime(t)
datetime(p, 'ConvertFrom', 'posixtime')

Respuesta aceptada

Jyotsna Talluri
Jyotsna Talluri el 20 de Mayo de 2020
While converting the posixtime to datetime specify the TimeZone using name-value pair,If not specified the posix times are considered as UTC times due to which you are not getting correct results.
z = datetime(p, 'ConvertFrom', 'posixtime', 'TimeZone','Europe/London');

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