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?

 採用された回答

Andrei Bobrov
Andrei Bobrov 2018 年 5 月 23 日

0 投票

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;

1 件のコメント

Megha
Megha 2018 年 5 月 23 日
@ Andrei Bobrov: yes thank you
it worked for me

サインインしてコメントする。

その他の回答 (2 件)

Megha
Megha 2018 年 5 月 23 日

1 投票

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 2018 年 5 月 23 日

0 投票

You might be able to use datetime() with 'convertfrom', 'posixtime'

3 件のコメント

Megha
Megha 2018 年 5 月 23 日
編集済み: Megha 2018 年 5 月 23 日
@Walter: ok. thank you. I got this value 1504224000.
Now how to convert this value to dd:mm:yyyy hh:mm:ss?
Walter Roberson
Walter Roberson 2018 年 5 月 23 日
>> datetime(1504224000,'convertfrom','posixtime')
ans =
01-Sep-2017 00:00:00
Megha
Megha 2018 年 5 月 23 日
@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!!

サインインしてコメントする。

カテゴリ

タグ

質問済み:

2018 年 5 月 23 日

回答済み:

2018 年 5 月 23 日

Community Treasure Hunt

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

Start Hunting!

Translated by