3
votes

Is there a way to convert time= 08/10/2014 23:34:02 to Epoch seconds (array of numbers) in MATLAB?

1
wait, you want Epoch seconds right? - GameOfThrows
yes i want epoch seconds. - Bob
What format is the date/time now? A string? - hbaderts
@hbaderts yes it is a string now - Bob

1 Answers

5
votes

So you want the Unix standard which can be calculated as follows:

InputDate=datenum('20141008 233402','yyyymmdd HHMMSS');
UnixOrigin=datenum('19700101 000000','yyyymmdd HHMMSS');

EpochSecond=round((InputDate-UnixOrigin)*86400);

>> 1412811242

EDIT for the OP's date format:

MYSTRING = '08/10/2014 23:34:02';
InputDate = datenum(MYSTRING,'dd/mm/yyyy HH:MM:SS');
UnixOrigin=datenum('19700101 000000','yyyymmdd HHMMSS'); %//This can stay the same, unless you want to change it for consistency.
EpochSecond=round((InputDate-UnixOrigin)*86400);

>>1412811242