[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Convert Epoch Date to Serial Date
From: |
Fritz Sonnichsen |
Subject: |
Re: Convert Epoch Date to Serial Date |
Date: |
Wed, 10 Apr 2019 15:04:27 -0400 |
User-agent: |
Mozilla/5.0 (Windows NT 6.1; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 |
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
On 4/10/2019 2:33 PM, Richardson, Anthony wrote:
Subject: Convert Epoch Date to Serial Date
I've looked thru the Octave time utilities and could not find a routine for this
purpose. Is there a simple function that receives the epoch-date and
converts it to a serial-date. (I need to feed the latter to the datetick
routine)
Thanks
Fritz
I believe localtime will return a structure that you can pull apart and feed to
datenum to get a serial date:
localtime(time())
ans =
scalar structure containing the fields:
usec = 839628
sec = 31
min = 32
hour = 13
mday = 10
mon = 3
year = 119
wday = 3
yday = 99
isdst = 1
gmtoff = 0
zone = Central Daylight Time
Tony Richardson