MATLAB Answers

Conversion of Gregorian date to decimal years

조회 수: 3(최근 30일)
Ahmet Hakan UYANIK
Ahmet Hakan UYANIK 2021년 5월 9일
댓글: Walter Roberson 2021년 5월 10일
I have time series given in gregorian time in seconds since 1992-01-01 00:00:00'. For example; 23853938,23853939...
How can i convert this gregorian time seconds to decimal years like 2010.544, 2010.545...

채택된 답변

Walter Roberson
Walter Roberson 2021년 5월 10일
basetime = datetime('1992-01-01 00:00');
gtime = 23853938
t1 = basetime + seconds(gtime)
t2 = dateshift(t1, 'start', 'year')
t3 = dateshift(t1, 'end', 'year')
fy = year(t1) + (t1-t2)./(t3-t2)
  댓글 수: 3
Walter Roberson
Walter Roberson 2021년 5월 10일
decyear() appears to require the Areospace Toolbox.
Also, setting the Format is not required for decyear()

댓글을 달려면 로그인하십시오.

추가 답변(0개)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by