How to Convert milliseconds to dd:mm:yyyy hh:mm:ss?

14 Ansichten (letzte 30 Tage)
Megha
Megha am 23 Mai 2018
Beantwortet: Megha am 23 Mai 2018
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?

Akzeptierte Antwort

Andrei Bobrov
Andrei Bobrov am 23 Mai 2018
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;

Weitere Antworten (2)

Megha
Megha am 23 Mai 2018
Well, I also got the solution from other google search results,
date = datestr(t/86400000 + datenum(1970,1,1));
Thank you @ Walter Roberson and @ Andrei Bobrov for spending your time on this.

Walter Roberson
Walter Roberson am 23 Mai 2018
You might be able to use datetime() with 'convertfrom', 'posixtime'
  3 Kommentare
Walter Roberson
Walter Roberson am 23 Mai 2018
>> datetime(1504224000,'convertfrom','posixtime')
ans =
01-Sep-2017 00:00:00
Megha
Megha am 23 Mai 2018
@walter this is the same o/p that i fed to my i/p!
while running
int32(floor(86400 * (datenum('01-Sep-2017') - datenum('01-Jan-1970'))))
as given under the link in your answers!!

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Time Series Objects finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by