help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Convert Epoch Date to Serial Date


From: Andrew Janke
Subject: Re: Convert Epoch Date to Serial Date
Date: Wed, 10 Apr 2019 15:22:05 -0400
User-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.13; rv:60.0) Gecko/20100101 Thunderbird/60.6.0



On 4/10/19 3:04 PM, Fritz Sonnichsen wrote:
Thanks Anthony.
   That seems to work after some code like this.
     t=localtime(epoch_date)
bf=sprintf("%d/%d/%d,%d:%d:%d",t.year+1900,t.mon+1,t.mday,t.hour,t.min,t.sec)
     DTformat='yyyy/mm/dd,HH:MM:SS';
     datenum(bf,DTformat)
     numerical_date = datenum(bf,DTformat); %days from January 0, 0000

after some thought the same result can be obtained as follows;
     numerical_date=  dtetmenum(1)/86400 + datenum(1970,1,1)

would be nice if this was included as an "epoch2serial" utility just to keep make it easy to remember!

cheers
Fritz

If Octave gets support for the @datetime class, this will become readily available: there's a `datetime(x, 'ConvertFrom','posixtime')` option that will do this conversion.

Cheers,
Andrew



reply via email to

[Prev in Thread] Current Thread [Next in Thread]