Datetime shows month name and not number

10 ビュー (過去 30 日間)
Tiago Dias
Tiago Dias 2019 年 8 月 16 日
コメント済み: madhan ravi 2019 年 8 月 16 日
Hello,
I want to find a specific datetime in my vector full of date time in the format of (10-09-2018 00:00:00) days-month-year hour-minute-second
I want to find this time:
datetime('10-09-2018 00:00:00','InputFormat','dd-MM-uuuu HH:mm:ss')
But matlab assume the 09 to be september and I need to be 09, because my vector has numbers for the months and not the short name
ans =
datetime
10-Sep-2018 00:00:00
Thanks for your time

採用された回答

madhan ravi
madhan ravi 2019 年 8 月 16 日
Change InputFormat to Format.
  2 件のコメント
Guillaume
Guillaume 2019 年 8 月 16 日
Not really!
'InputFormat' specify the format of the input string, so is required for matlab to decode that string properly. It is independent of the 'Format' property which controls how the datetime is displayed.
If you want the display format to match the input format, you either have the specify it twice:
datetime('10-09-2018 00:00:00', 'InputFormat', 'dd-MM-uuuu HH:mm:ss', 'Format', 'dd-MM-uuuu HH:mm:ss')
A bit of a chore (particularly if you decide to change the format)!, so there's an easier way:
datetime('10-09-2018 00:00:00','InputFormat','dd-MM-uuuu HH:mm:ss', 'Format', 'preserveinput')
madhan ravi
madhan ravi 2019 年 8 月 16 日
Thank you, Guillaume!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeDownloads についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by