How do I convert UTC time to Unix time?

18 visualizaciones (últimos 30 días)
Jen B
Jen B el 19 de Sept. de 2023
Comentada: Dyuman Joshi el 21 de Sept. de 2023
I have a datafile with time in UTC, for example: 192503.000 where the format is hhmmss.ss format, where hh is hours (00–23), mm is minutes, and ss.ss is seconds and fractions of seconds.. How do I convert this to Unix time?
  1 comentario
James Tursa
James Tursa el 19 de Sept. de 2023
You are going to need a date (y,m,d) to go with that to calculate Unix Time.

Iniciar sesión para comentar.

Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 19 de Sept. de 2023
Editada: Dyuman Joshi el 19 de Sept. de 2023
%Example
y = datetime('now','TimeZone','UTC')
y = datetime
19-Sep-2023 16:47:22
%Get time in UNIX format
z=posixtime(y)
z = 1.6951e+09
%Change the display format
format longg
z
z =
1695142042.43009
If you have data in any other format then datetime(), convert it to datetime() and the use posixtime
  4 comentarios
Jen B
Jen B el 21 de Sept. de 2023
Hi, sorry! Yes, this helped. Thank you!
Dyuman Joshi
Dyuman Joshi el 21 de Sept. de 2023
Glad to have helped!

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

Productos


Versión

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by