Convert double to DateTime format?

조회 수: 39 (최근 30일)
Fredrick Neo
Fredrick Neo 2018년 6월 5일
편집: dpb 2018년 6월 5일
How to convert numeric double types into datetime 'dd/mm/yyyy hh.mm.ss' format? Example: 20180304122050 -> become 04/03/2018 12:20:50
  댓글 수: 6
Paolo
Paolo 2018년 6월 5일
Is OP not just asking for this?
x = num2str(20180304122050);
date = datetime(x,'InputFormat','yyyyMMddhhmmss','Format','dd/MM/yyyy hh:mm:ss');
date:
04/03/2018 12:20:50
dpb
dpb 2018년 6월 5일
편집: dpb 2018년 6월 5일
Paolo -- looks like probably simplest solution to code; can do without the temporary even in actual implementation.
Stephen -- I meant "great" in the sense of the conversion would be trivial to code if the additional formatting strings were parsed; not so much that it is a great encoding scheme. Altho I will say I have done such things in previous life when working in constrained memory systems where the storage between 8 and 12/14 bytes was important--that's been almost 40 yr ago by now, though, granted! :)

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

답변 (0개)

카테고리

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