Frustrating datetime and datestr
조회 수: 9 (최근 30일)
이전 댓글 표시
Hey I got this
hund = datetime(end_stamp, 'convertfrom','posixtime')
% which give this:
hund =
datetime
05-Nov-2018 00:00:00
Because this one hit time 00:00:00 and I use datestr i get this:
hund = datestr(hund)
hund = '05-Nov-2018'
But I need to get the exact line as a string:
hund = '05-Nov-2018 00:00:00'
Anyone have an idea ?
댓글 수: 1
Stephen23
2021년 12월 3일
Rather than using deprecated DATESTR, it is much better to stick with the DATETIME object itself:
t = datetime('03-Nov-2018 00:00:00','InputFormat','dd-MMM-yyyy HH:mm:ss')
t.Format = 'dd-MMM-yyyy HH:mm:ss'
채택된 답변
추가 답변 (1개)
Martin
2018년 11월 11일
댓글 수: 3
Stephen23
2021년 12월 3일
편집: Stephen23
2021년 12월 3일
"I don't know if there is a reason"
The deprecated DATESTR/DATENUM, etc used a simple, consistent, venerable format presumably devised by TMW.
In contrast DATETIME uses the Unicode Locale Data Markup Language (LDML) standard for dates and times:
as documented here:
참고 항목
카테고리
Help Center 및 File Exchange에서 Data Preprocessing에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!