How do I convert relative Gregorian days since 1935-01-01 to calendar datetime (days with hours,mins,sec)?
13 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Minh Tran
am 30 Nov. 2018
Kommentiert: Peter Perkins
am 11 Dez. 2018
I have a netcdf dataset that reports timestamps as decimal values where each represents the "Gregorian" days since 1935-01-01 (1935, January 1), 00:00:00 UTC. I'd like to convert those decimal values to datetime values that we're use to: Year/Month/Day Hours:Minutes:Seconds.
I've never asked myself "how do we compute the calendar days to tell which day of the week it is?" or "what is the anchor date that we use to compute calendar date?" so the subject of "Gregorian" vs. "Julien" calendar is new to me. What does Matlab use?
Attached is the netcdf file I'm working with. You can get the datastructure with the dates using the matlab function call:
ncread('NorthPlatte_2.nc', 'date_time');
0 Kommentare
Akzeptierte Antwort
Guillaume
am 30 Nov. 2018
Probably,
dt = datetime(yourtimestamps*24*3600, 'ConvertFrom', 'epochtime', 'Epoch', '1935-01-01')
1 Kommentar
Peter Perkins
am 11 Dez. 2018
Or perhaps
datetime(1935,1,1,'Format','dd-MMM-yyyy HH:mm:ss') + days(yourtimestamps)
It's almost certain that since the epoch in your file is described as 1935-01-01 (1935, January 1), 00:00:00 UTC, that you don't need to deal with Daylight Saving Time, but in general, yoiu;d want
datetime(1935,1,1,'Format','dd-MMM-yyyy HH:mm:ss') + caldays(yourtimestamps)
if DST were an issue. In any case, using caldays never hurts.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Calendar finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!