converting dateTime RFC3339 to matlab datetime format

4 ビュー (過去 30 日間)
CV
CV 2020 年 10 月 14 日
コメント済み: CV 2020 年 10 月 15 日
Hi,
I want to convert tiem format RFC3339 to matlab datetime format.
the RFC3339 format looks like this:
'2020-10-07T14:50:01.742Z'
I want to convert in such a way that i can be able to see the millisconds as well.
Thanks.

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 14 日
編集済み: Ameer Hamza 2020 年 10 月 14 日
Try this
str = '2020-10-07T14:50:01.742Z';
dt = datetime(str, 'InputFormat', 'yyyy-MM-dd''T''HH:mm:ss.SSS''Z''');
Result
>> dt
dt =
datetime
07-Oct-2020 14:50:01
  2 件のコメント
Steven Lord
Steven Lord 2020 年 10 月 14 日
If you want the datetime to be displayed the same way as the date and time was displayed in the text specify both the 'InputFormat' and the 'Format'.
str = '2020-10-07T14:50:01.742Z'
fmt = 'yyyy-MM-dd''T''HH:mm:ss.SSS''Z''';
dt = datetime(str, 'InputFormat', fmt, 'Format', fmt)
CV
CV 2020 年 10 月 15 日
Thanks a lot both solutions worked.
as i want the milliseconds as well the solution form steven worked quite well.

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

その他の回答 (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