Convert double to DateTime format?
86 views (last 30 days)
Show older comments
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 Comments
Paolo
on 5 Jun 2018
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
on 5 Jun 2018
Edited: dpb
on 5 Jun 2018
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! :)
Answers (0)
See Also
Categories
Find more on Time Series Objects in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!