フィルターのクリア

converte UNIX time to Human readable format.

2 ビュー (過去 30 日間)
buer
buer 2014 年 12 月 19 日
コメント済み: buer 2014 年 12 月 30 日
Hello,
Work is almost done, but there came one more problem: how can I converte the UNIX time to human readable format, like ISO086..
My UNIX time is in int64 format, for example: 1352434077. So when I tried to converte it with this code:
unix_epoch = datenum(1970,1,1,0,0,0);
for i=1:1:size(data_mat)
matlab_time(i,1) = data_mat(i,1)./86400 + unix_epoch;
end
It gave 735087..not something like YYYY-MM-DD: hh:mm:ss ...can anyone gave me a hint? Thanks a lot!

採用された回答

Bjorn Gustavsson
Bjorn Gustavsson 2014 年 12 月 19 日
Take a look at datestr (or some of the other functions in the date-family):
datestr(matlab_time,'yyyymmddTHH:MM:SS')
or whatever format you might choose.
HTH
  8 件のコメント
Bjorn Gustavsson
Bjorn Gustavsson 2014 年 12 月 23 日
I guess you should do the typecasting to double ASAP, that is on the Data(1:10,1) before dividing by 86400 - as it is now that division will give you an int - and that corresponds to midnight since the time of day is in fractions of a day...
HTH
buer
buer 2014 年 12 月 30 日
Thanks Bjorn....it is really about the typecasting..thanks a lot

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDates and Time についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by