Search code examples
matlabdatetimetimestampdate-conversion

Convert Matlab Timestamp in Date


I have imported a lot of timestamp in Matlab using this format: yyyy-mm-dd HH:MM:SS.FFF.

Now I have a vector like this one:

>> way(1:70,2)

ans =

   1.0e+05 *

   7.360197487028009
   7.360197487087731
   7.360197487264699
   7.360197487323611
   7.360197487519444
   7.360197487572569
   7.360197487750464
   7.360197487809028
   7.360197487988425
   7.360197488046759
   7.360197488225000
   7.360197488284375
   7.360197488463195
   7.360197488521990
   7.360197488700810
   7.360197488759027
   7.360197488937847
   7.360197488996875
   7.360197489175116
   7.360197489233681
   ...

I would like obtain a string in this format: yyyy-mm-dd HH:MM:SS. I have tried with this post but do not work (I have years from 2013 and more).

Apologize if the question is duplicate, but I have no found an answer in SX and in the web.

Thank you.


Solution

  • maybe this?

    datestr(way(1:70,2),'yyyy-mm-dd HH:MM:SS')
    

    e.g. for the first value in the list:

    datestr(1e5*7.360197487028009,'yyyy-mm-dd HH:MM:SS')
    ans =
    
    2015-02-24 17:58:07
    

    HTH