How to convert the following UTC to serial date number?

26 ビュー (過去 30 日間)
Anirban Mandal
Anirban Mandal 2022 年 1 月 25 日
コメント済み: Steven Lord 2022 年 1 月 25 日
I have a UTC data in the format YYYY-DOYThh:mm:ss.fffZ (Example-2018-345T02:19:02.175Z). What format can I use for it to convert it into serial date number using datenum? The main issue I am facing is with the format DOY as I wasn't able to find any suitable format for this in the datenum documentation. However, I can take care of the rest of them easily. Here I am attaching a sample code I used for this case. The first line is there as I am extracting UTC from a dataset.
utc_t=data(:,5);
match=["T","Z"];
utc=erase(utc_t,match);
format='yyyy-HH:MM:SS:FFF';%This is incomplete as I have not incorporated DOY format here
time=datenum(utc,format);

採用された回答

Walter Roberson
Walter Roberson 2022 年 1 月 25 日
format long g
utc_t = '2018-345T02:19:02.175Z'
utc_t = '2018-345T02:19:02.175Z'
utc_dt = datetime(utc_t, 'InputFormat', "uuuu-DDD'T'HH:mm:ss.SSS'Z'")
utc_dt = datetime
11-Dec-2018 02:19:02
time = datenum(utc_dt)
time =
737405.096552951
  2 件のコメント
Anirban Mandal
Anirban Mandal 2022 年 1 月 25 日
Thanks
Steven Lord
Steven Lord 2022 年 1 月 25 日
Unless you absolutely need to work with the serial date numbers, I'd advise you to work with the datetime array utc_dt instead of the double array time. You should be able to do just about everything with datetime that you could do with the date numbers. If you find something you can do with datenums that you can't with datetime, please describe what you're trying to do.

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

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