Convert time column from hours to ddmmmyyyy HH:MM:SS
조회 수: 2 (최근 30일)
이전 댓글 표시
My time column is in hours (0000 01JAN1900=0hr) and starts from 999,312h (meaning 0000 01JAN2014). How would I convert a column vector of times (hrs) into a column of time in ddmmmyyyy HH:MM:SS format?
채택된 답변
Stephen23
2020년 11월 5일
편집: Stephen23
2020년 11월 5일
dth = 999312 + [0;1;12;24;36;42;31*24] % fake data
dtm = datetime(dth*60*60, 'ConvertFrom','epochtime','Epoch','1900-01-01', 'Format','ddMMMyyyy HH:mm:ss')
댓글 수: 7
Peter Perkins
2020년 11월 20일
Just to be clear: "whereas MATLAB counts days from day zero of year zero" refers to the older way of working with dates/times in MATLAB. The newer better way to do it is, as Stephen says, datetime, which doesn't work like that. datetime has been around since R2014b.
추가 답변 (1개)
Steven Lord
2020년 11월 5일
dth = 999312 + [0;1;12;24;36;42] % fake data
start = datetime(1900, 1, 1);
dates = start + hours(dth)
참고 항목
카테고리
Help Center 및 File Exchange에서 Dates and Time에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!