How do I convert UTC time to Unix time?

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 Comment

You are going to need a date (y,m,d) to go with that to calculate Unix Time.

Sign in to comment.

 Accepted Answer

%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 Comments

I'll give this a try, thank you!
Hi, sorry! Yes, this helped. Thank you!
Glad to have helped!

Sign in to comment.

More Answers (0)

Categories

Products

Release

R2020b

Asked:

on 19 Sep 2023

Commented:

on 21 Sep 2023

Community Treasure Hunt

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

Start Hunting!