MATLAB: Adapting the datetime function

datetimeinputformat

Hi everybody!
I got: a string representing a time in the format of 'dd.MM.yyyy HH:MM:SS.SSS' (actually not only one string, but a whole list)
I'd like to: transform my string into a datetime with the help of the function "datetime"
That's what I tried so far:
With the following line of code I'm always getting the error message "Error using datetime (line 639) Input data must be a numeric array, a string array, a cell array containing character vectors, or a char matrix."
date=datetime(t.r(:,1),'Inputformat','dd.MM.yyyy HH:MM:SS.SSS');
Unfortunately: I don't know how to adapt the datetime function properly! Can you please help me?

Best Answer

You must use the correctly specifiers for 'InputFormat', mm for minutes and ss for seconds.
str = "13.07.2018 09:59:30.333"
datetime(str,'InputFormat','dd.MM.yyyy HH:mm:ss.SSS')