Date conversion using GMT
4 次查看(过去 30 天)
显示 更早的评论
I have a specific application in which I am reading in data into an array that includes a year (as an individual cell) and a GMT day. I need to convert the GMT day into an actual date using the year. If the year is in variable yr and GMT date in dGMT, I assumed that I could use the datestr function as follows:
d = datestr(addtodate(dGMT),floor(yr*365.25),'day'))
where datestr of the GMT returned the date in year 0000, and I simply add the amount of days that have elapsed since 1/1/0000. However, the data that is computed is off by about 2 weeks.
I did some investigating, and tried the above line of code with various years and dGMT=1.
I got the following: K>> datestr(addtodate((1),floor(1582*365.25),'day'))
ans =
31-Dec-1581
K>> datestr(addtodate((1),floor(1583*365.25),'day'))
ans =
10-Jan-1583
It seems that between year 1582 and 1583 10 days get added. Can anyone explain why, or possibly suggest another way to get the date?
0 个评论
回答(1 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Time Series Objects 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!