How to Convert milliseconds to dd:mm:yyyy hh:mm:ss?
조회 수: 42 (최근 30일)
이전 댓글 표시
I have rows that contains 'gregorian' Date and time for each observation in milliseconds since 1970-01-01 00:00:00.0 UTC.
How can I convert this millisecond into dd:mm:yyyy hh:mm:ss?
댓글 수: 0
채택된 답변
Andrei Bobrov
2018년 5월 23일
T = datetime(1970,1,1,0,0,0,0,'TimeZone','UTC','F','uuuu-MM-dd''T''HH:mm:ss.SSS Z');
addMS = milliseconds(cumsum([0;randi(2e8,10,1)]));
out = T + addMS;
추가 답변 (2개)
Walter Roberson
2018년 5월 23일
You might be able to use datetime() with 'convertfrom', 'posixtime'
Or see https://www.mathworks.com/matlabcentral/answers/6117-convert-date-to-unix-time#answer_8508 for the opposite way, which you could then invert.
댓글 수: 3
Walter Roberson
2018년 5월 23일
>> datetime(1504224000,'convertfrom','posixtime')
ans =
01-Sep-2017 00:00:00
참고 항목
카테고리
Help Center 및 File Exchange에서 Calendar에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!