MATLAB: How to convert time in its standard form to seconds convertsec Hi Team, I have time in its standard format Hh:mm.ss loaded from excel sheet. how can i convert it into complete seconds which helps me in further calculation. Best Answer Use datenum. t1 = '12:45:07'; t2 = '13:45:07'; dt_sec = round((datenum(t2,'HH:MM:SS') - datenum(t1,'HH:MM:SS'))*(24*3600)) dt_sec = 3600 Related SolutionsMATLAB: 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 MATLAB: Datestr not working properly datestr(datenum(raw,'dd/mm/yyyy HH:MM:SS'), 'yyyy-mm-dd HH:MM:SS') Related QuestionDatetime problem of converting stringConverting hh:mm:ss into secondsHow to include milliseconds when converting datestr to datetimeHow to convert 5.5 hour to 05:30:00 HH:MM:SS format
Best Answer