Matlab is mixing MONTH and DAY up
7 views (last 30 days)
Hello, I have a datetime array where the format is dd/MM/yyyy, but when I used ymd(), Matlab tells me that day is month and month is day. Using format() just rearranges the date but retains the confusion between day and month.
How do I rectify this, how can I dictate to Matlab which is the month and which is the day?
9 %this is actually the day
d = %this is actually the month
Star Strider on 22 Mar 2021
Edited: Star Strider on 22 Mar 2021
D = load('gps.mat');
gps = D.gps;
LOCALDATETIME = datetime(string(gps.LOCALDATE),'InputFormat','dd/MM/yyyy', 'Format','dd/MM/yyyy HH:mm:ss') + gps.LOCALTIME;
First_5_Rows = LOCALDATETIME(1:5)
5×1 datetime array
Since ‘gps.LOCALDATE’ is already a datetime array, converting it first to a string variable allowed datetime to parse it correctly.
EDIT — Added explanation.