MATLAB Answers

0

How to reset military datetime in matlab?

Asked by Wiktoria Glogowska on 14 Aug 2019
Latest activity Answered by Rik
on 14 Aug 2019
Hello,
I have a problem with the way that Matlab reads user time input from the gui. When user inputs 07-01-2019 00:00:00 matlab reads the variables as 07-01-2019 12:00:00. Same for the loaded data timeframe. Also user cannot input any 24h military time, like for example input of : 07-01-2019 22:00:00, gives the error:
Unable to parse '01-01-2019 22:00:00' as a date/time using the format 'dd-MM-yyyy hh:mm:ss'.
I have used the command below to reset the default settings before, but not in the current script. Would that have any effect on how matlab reads the time? Any help would be appreciated.
datetime.setDefaultFormats('default','yyyy-MM-dd hh:mm:ss')

  0 Comments

Sign in to comment.

1 Answer

Answer by Rik
on 14 Aug 2019

As you can read in the doc, the hh identifier is a 12h system. If you want 24h, you need to use HH in your format.

  0 Comments

Sign in to comment.