datetime default stetings 12/24

42 vues (au cours des 30 derniers jours)
Lieke Numan
Lieke Numan le 9 Août 2019
Déplacé(e) : Dyuman Joshi le 19 Déc 2023
I used datetime.setDefaultFormats('default','hh:mm:ss yyyy-MM-dd') to set my default setting for datetime. However, time is running up to 12 instead of 24 hours. How can I change this?

Réponse acceptée

Are Mjaavatten
Are Mjaavatten le 10 Août 2019
Use HH instead of hh for the hours:
>> datetime.setDefaultFormats('default','hh:mm:ss yyyy-MM-dd')
>> t = datetime(2019,8,10,17,30,0)
t =
05:30:00 2019-08-10
>> datetime.setDefaultFormats('default','HH:mm:ss yyyy-MM-dd')
>> t
t =
17:30:00 2019-08-10
  2 commentaires
Guillaume
Guillaume le 10 Août 2019
See the Format documentation of datetime, which lists all the format and indeed clearly states:
h Hour, 12-hour clock notation using one or two digits
hh Hour, 12-hour clock notation using two digits
H Hour, 24-hour clock notation using one or two digits
HH Hour, 24-hour clock notation using two digits
Lieke Numan
Lieke Numan le 13 Août 2019
Déplacé(e) : Dyuman Joshi le 19 Déc 2023
Thanks a lot!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Clocks and Timers dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by