필터 지우기
필터 지우기

conversion of seconds to date

조회 수: 2 (최근 30일)
Uday
Uday 2011년 8월 1일
I have some time data in which time:units = "seconds since 2005-01-01". I would like to convert this seconds to datevc.
I have tried time= datenum(double(timeTm)/86400 + datenum([year month day hour minute second])); but some how I get result date 3 year ahed. ( instead of 2005 it shows me 2008).
  댓글 수: 1
Rick Rosson
Rick Rosson 2011년 8월 1일
Can you please show more of your MATLAB code? Ideally, please post a set of complete, working code that we can run in MATLAB.
Thanks!

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

채택된 답변

Fangjun Jiang
Fangjun Jiang 2011년 8월 1일
It worked for me.
>> t=86400;
datestr(t/86400+datenum(2005,1,1))
ans =
02-Jan-2005
>> datestr(t/86400+datenum(2005,1,1,0,0,0))
ans =
02-Jan-2005

추가 답변 (1개)

Kelly Kearney
Kelly Kearney 2011년 8월 1일
Your code looks like it should work. Have you verified that your data uses actual dates, with leap years, as opposed to a 365-day calendar? The latter could cause your results to be off by a few days, though three years seems like a different problem.
Also, are you certain the data is supposed to fall in the year 2005, rather than 2008? All your time values are less than 31536000? Just because the data uses 2005 as a reference year doesn't necessarily mean the data is located in that year.

카테고리

Help CenterFile Exchange에서 Dates and Time에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by