MATLAB: Converting hh:mm:ss into seconds hh:mm:ss into ss Hi all, I want to read the vectors which are hh:mm:ss (14:35:59.812) format and convert it to seconds. How can I do this in matlab? Best Best Answer Is this what you are looking for?t='14:35:59.812';[Y, M, D, H, MN, S] = datevec(t);H*3600+MN*60+S Related SolutionsMATLAB: How to include milliseconds when converting datestr to datetime posix_timestamp = 1.524216883857000e+09;datetime(posix_timestamp,'convertfrom','posixtime', 'Format', 'yyyy-MM-dd HH:mm:ss.SSS') MATLAB: Time difference in ‘HH:mm:ss,SSSSSS’ format t0 = '15:30:25,123456't0 = '15:30:25,123456't1 = '16:45:30,123457't1 = '16:45:30,123457'theFormat = 'hh:mm:ss.SSSSSS';timeStart = duration(replace(t0, ',', '.'), 'InputFormat', theFormat, 'Format', theFormat)timeStart = duration 15:30:25.123456 timeEnd = duration(replace(t1, ',', '.'), 'InputFormat', theFormat, 'Format', theFormat)timeEnd = duration 16:45:30.123457 elapsed = timeEnd - timeStartelapsed = duration 01:15:05.000001 Related QuestionHow to convert 5.5 hour to 05:30:00 HH:MM:SS formatDatetime problem of converting stringDoes a single date vector with a large value for the seconds element return a vector of six dates when passed to DATESTR in MATLAB 7.7 (R2008b)Converting times from excel file using datetime, datestr, and datenum
Best Answer