MATLAB: How to add msec to datetime

MATLABmatlab function

Hello all.
I have a string array of times i'm trying to convert into datetime format.
the string array is as follows:
'12/24/2019 02:42:42:451 PM'
from it i take the parameters: year, month, day, hour (based on PM or AM), min, sec, msec.
and when trying to convert it into datetime using:
Ts = datetime(year,month,day,hour,min,sec,milli_sec,'InputFormat','yyyy-MM-dd HH:mm:ss.SSS');
I get:
datetime
24-Dec-2019 14:42:42
without the msec.
anyone knows why doesn't it take the msec into consideration?

Best Answer

Please set the display format to show millisecond, like:
>> Ts.Format = 'uuuu/MM/dd HH:mm:ss.SSS';
>> Ts
Ts =
datetime
2019/12/24 14:42:42.451