Friday, August 29, 2014

Convert Epoch Unix Time to Normal Date and Time in Matlab

Suppose, you start with a vector time_unix, then:


time_unix = 1339116554872; % example time
time_reference = datenum('1970', 'yyyy'); 
time_matlab = time_reference + time_unix / 8.64e7;
time_matlab_string = datestr(time_matlab, 'yyyy mm dd HH:MM:SS.FFF')

    time_matlab_string =

    2012 06 08 00:49:14.872

Some notes:

1) 8.64e7 is number of milliseconds in a day.
3) Matlab does not apply any time-zone shifts, so the result is the same UTC time.

No comments:

Post a Comment