필터 지우기
필터 지우기

How to change seconds since 1st January 1985 to YYYY-MM-DD-HR-M-S format?

조회 수: 1 (최근 30일)
David
David 2013년 7월 29일
I am a new user of MATLAB and was hoping to get some help to what is probably a very basic question to most of you. I am using data that currently represents time in seconds since 1st January 1985 and have been trying to change this to a format of YYYY-MM-DD-HR-M-S, however my attempts have been completely unsuccessful thus far. The data I am using ranges from 2003-2008. This is as much as I have come up with so far.
> t=86400; %86400 seconds in a day
> datestr(t/86400+datenum(1985,1,1))
Any help or guidance would be really appreciated. Cheers
  댓글 수: 1
Jan
Jan 2013년 7월 29일
What do you get as result of your code and what do you expect? I'd suggest exactly the same way, because it is the most efficient one.

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

답변 (2개)

Azzi Abdelmalek
Azzi Abdelmalek 2013년 7월 29일
편집: Azzi Abdelmalek 2013년 7월 29일
dat0='01-01-1985 00:00:00'
dat00=datevec(dat0,'dd-mm-yyyy HH:MM:SS')
a=95604
dat00(6)=dat00(6)+a
new_de=datestr(datenum(dat00))
  댓글 수: 1
Jan
Jan 2013년 7월 29일
Your dat00 contains the same information as David's datenum(1985,1,1). Adding the number of seconds to the 6.th component of the date vector is the same as adding t/86400 to the datenumber. Therefore I do not see the difference to the original approach.

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


Iain
Iain 2013년 7월 29일
seconds_since_1985 = 981364894; %
days_since_1985 = seconds_since_1985 / 86400;
datestr(days_since_1985 + datenum('1/1/1985'), 'YYYY-MM-DD-hh-mm-ss')
  댓글 수: 1
Jan
Jan 2013년 7월 29일
This looks also identical to the original version.
"MM" means minutes, while "mm" means months. So you have to swap upper- and lower-case.

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

카테고리

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