How do I convert UTC time to Unix time?

15 次查看(过去 30 天)
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 个评论
James Tursa
James Tursa 2023-9-19
You are going to need a date (y,m,d) to go with that to calculate Unix Time.

请先登录,再进行评论。

采纳的回答

Dyuman Joshi
Dyuman Joshi 2023-9-19
编辑:Dyuman Joshi 2023-9-19
%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 个评论
Jen B
Jen B 2023-9-21
Hi, sorry! Yes, this helped. Thank you!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

产品


版本

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by