convert the datenum to date

181 ビュー (過去 30 日間)
ZITING ZHOU
ZITING ZHOU 2019 年 5 月 15 日
コメント済み: Guillaume 2019 年 5 月 15 日
there is an datebum which is 726329
How can I convert it into form of DD-MM-YY

回答 (1 件)

Guillaume
Guillaume 2019 年 5 月 15 日
d = 726329;
datetime(d, 'ConvertFrom', 'datenum', 'Format', 'dd-MM-yy') %recommended, although I'd recomend using yyyy instead of yy
%or
datestr(d, 'dd-MM-yy') %not recommended
I would recommend that you use the newer datetime instead of the old datestr. I would also recommend that you use 4 digits for the year. Hasn't Y2K and all the subsequent scares taught us enough that using 2 digits for the year is foolish.
  2 件のコメント
Jan
Jan 2019 年 5 月 15 日
編集済み: Jan 2019 年 5 月 15 日
@Guillaume: Y2K does not work here. I've tried 'dd-MM-kk', but get an error message only.
Guillaume
Guillaume 2019 年 5 月 15 日
@Jan, Y2k is not a format. It's the short name for the scare we had before 2000 because critical computers stored the year using only two digits. More recently, we had the gps rollover scare again because programmers skimped on the number storage.
There's really no reason not to store the year using 4 digits and remove any kind of ambiguity over which century/millenium is meant. 2088 is only 69 years away, some of the young ones here may still be alive by then, so remove the ambiguity with 1988.

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

カテゴリ

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