Convert timestamp to integer
datetime, matlab
Solution
Try `datenum` with a format specifier:
>> datenum(s,'yyyy-mm-dd-hh_MM_ss')
ans =
7.3564e+05
Convert to epoch:
mtime = datenum(s,'yyyy-mm-dd-hh_MM_ss');
unix_time = round(8.64e7 * (mtime - datenum('1970', 'yyyy')))
Problem
How can I convert the following timestamp into the an integer form, ideally milliseconds after 1970.... ``` s = '2014-02-11-00_40_05' ``` I have tried using: ``` out = datevec(s) ``` However I receive an error saying 'Too many date fields in 2014-02-11-00_40_0' Thanks