How to include milliseconds when converting datestr to datetime

60 ビュー (過去 30 日間)
Stephanie Buadu
Stephanie Buadu 2018 年 5 月 18 日
コメント済み: Stephanie Buadu 2018 年 5 月 19 日
I am trying to convert a date string of the form 20-04-2018 09:37:46.657 ('dd-mm-yyyy HH:MM:SS.FFF') to a datetime, but I cannot get the right input format. I have a long time series of 20 measurements pr seconds, so the milliseconds are essential. Could I change the format in one or both of the functions to get the right result?
Here is my code:
posix_timestamp = 1.524216883857000e+09;
str = datestr(posix_timestamp/86400 + datenum('1/1/1970'), 'dd-mm-yyyy HH:MM:SS.FFF');
datetime(str, 'InputFormat', 'dd-mm-yyyy HH:MM:SS.FFF' );

採用された回答

Walter Roberson
Walter Roberson 2018 年 5 月 18 日
posix_timestamp = 1.524216883857000e+09;
datetime(posix_timestamp,'convertfrom','posixtime', 'Format', 'yyyy-MM-dd HH:mm:ss.SSS')

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by