I have an array of Epoch times that include fractional (nanoseconds). I have reviewed Converting Epoch to Date in Matlab but still cannot seem to convert to the correct date. I must be missing something simple.
Example data: 1548348497.191261
I am using the code in the link above.
time_unix_nanos = 1548348497.191261;
millis = round(time_unix_nanos);
nanos = time_unix_nanos - 1e6 * millis;
time_matlab = round(864e5 * (millis - datenum('1970', 'yyyy')));
s = [datestr(time_matlab, 'yyyy-mm-dd hh:mm:ss.FFF;), num2str(nanos)];
fprintf('s: = %f\n',s);
Two desired outputs Full date format: yyyy-mm-dd HH:mm:ss.SSS Just time format: HH:mm:ss.SSS
Thanks in advance!