Convert epoch to human readable data and time
140 次查看(过去 30 天)
显示 更早的评论
Hi,
i have a vector of time in epoch format (read as double in Matlab). I have to convert all the elements in a format HH:MM:SS till milli or even nano seconds if it is possible.
The vector time is related to data acquired on 20th October 2021.
Can someone help me please ?
Thank you in advance
1 个评论
Star Strider
2021-12-1
What is the epoch time for midnight on 20th October 2021, and 1 and 60 seconds later?
.
采纳的回答
更多回答(2 个)
Steven Lord
2021-12-1
What's the unit of time a value of 1 in your epochtime represents? Seconds, microseconds, nanoseconds, etc.?
t = 6000;
start = datetime('today') % Use midnight today as the start of the epoch
dt1 = datetime(t, 'ConvertFrom', 'epochtime', 'Epoch', start) % 6000 seconds after the epoch
dt2 = datetime(t, 'ConvertFrom', 'epochtime', 'Epoch', start, ...
'TicksPerSecond', 1000) % 6000/1000 seconds after the epoch
You may also want to look at the table in the entry for the dateType input argument to datetime to see if one of the provided options matches what your time data represents: 'ntp', '.net', or 'ntfs' perhaps, since they each represent a number of "clock ticks" that are a small fraction of a second?
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!