Convert double to DateTime format?

35 次查看(过去 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