How to change time stamp to readable date and time without giving reference time ?
3 views (last 30 days)
Show older comments
Naveed Khan
on 28 Feb 2016
Answered: Peter Perkins
on 7 Mar 2016
Below code is to generate Date and Time from a timeStamp but with the help of reference date and time (refTime). However , I need to generate date and time without giving reference time. How can i do that? Thanks in advance.
refTime = [2016,08,02,10,28,52];
refNum = datenum(refTime);
% refStr = datestr(refNum,'yyyy-mm-dd HH:MM:SS.FFF');
Dat_timeStamp = [1.454958517009081e+18,1.454958517014576e+18, 1.454958517018680e+18];
% Processing data
% dn = 24*60*60*1000*1000; % Microseconds! I have changed this equation to many options but nothing was helpful
for i = 1 : size(Dat_timeStamp,2)-1
usecs = double(Dat_timeStamp(1,i+1)) - double(Dat_timeStamp(1,1));
secsDiff = usecs / 1e9;
matDateTime = refNum + secsDiff / (24*60*60);
gzStr{i,1} = datestr(matDateTime,'yyyy-mm-dd HH:MM:SS'); % I can't use 'SS.FFFFFF'
end;
3 Comments
Accepted Answer
More Answers (1)
Peter Perkins
on 7 Mar 2016
When I do this
>> datetime('08-Feb-2016 10:28:52','Format','dd-MMM-yyyy HH:mm:ss.SSSSSSSSS') - seconds(1.454956105656222e+9)
ans =
31-Dec-1969 16:00:26.343777832
It makes me suspect that the issue is not only time zones, not only floating point round-off, but also leap seconds.
0 Comments
See Also
Categories
Find more on Logical in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!