How do I apply the convert epoch time formula to an array?
Mostrar comentarios más antiguos
Hi, I have an array of 522 epoch time stamps that I want to convert to human readable form. I am not sure how to convert it and plot it. Your help would be greatly appreciated. Thanks!
time_unix = 1480518828; % example time
time_reference = datenum('2017', 'yyyy');
time_matlab = time_reference + time_unix / 8.64e7;
time_matlab_string = datestr(time_matlab, 'yyyymmdd HH:MM:SS.FFF')
figure('Color', 'White')
reftime=dataset1 (:,1); %Follower Actual (Excel column G2)
ylabel('TBD1')
xlabel('TBD2')
legend('Epock Time''Location', 'northwest')
title('Ephoch Time Conversion')
grid
Respuestas (1)
Walter Roberson
el 26 de En. de 2017
0 votos
That is not the correct conversion for Unix or Posix time. The time base is January 1st 1970 utc. The number field is either seconds since then (traditional) or milliseconds since then (commonly seen), except that Posix time does not account for leap seconds so you have to be careful on the conversion.
I recommend that if you have a sufficiently new MATLAB that you use datetime() with 'convertfrom', 'posixtime'
3 comentarios
Lidia Toscano
el 26 de En. de 2017
Walter Roberson
el 26 de En. de 2017
You can pass the array as the first parameter to datetime
Kerman Sekhon
el 6 de En. de 2019
Hello,
Thank you for your guidance. I was wondering what you meant by pass the array as the first parameter to datetime? Thank you for your time!
Kind Regards
Categorías
Más información sobre MATLAB en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!