How to work with Unix timestamps in Matlab?

后端 未结 2 570
清酒与你
清酒与你 2020-12-01 11:27

I have some data files with Unix timestamps (in this case, number of milliseconds since Jan 1, 1970 00:00 UTC). I would like to convert these to human-friendly date/time str

2条回答
  •  情话喂你
    2020-12-01 11:54

    Newer versions of MATLAB (verified in R2015a) have a datetime type that is useful for working with and formatting dates and times. You can convert UNIX timestamps into a MATLAB datetime with

    dt = datetime( unix_time, 'ConvertFrom', 'posixtime' );
    

    and then use datestr as before for formatting as a string

    datestr( dt )
    

提交回复
热议问题