How would I convert years to date time?
2 views (last 30 days)
Show older comments
Ali Almakhmari on 9 Aug 2022
I have many values given in years. How would I convert them to a date and time in UTC? For example, one of the values I have is 2022.1765918316. Its obviously the year 2022 and sometime in february, but how would I go about getting the exact date AND time (hours, minutes, and seconds) in UTC?
Stephen23 on 9 Aug 2022
Edited: Stephen23 on 9 Aug 2022
N = 2022.1765918316;
D = datetime(fix(N),1,1) + calyears([0;1]);
T = D(1) + diff(D)*mod(N,1)
More Answers (0)
Find more on Dates and Time in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!Start Hunting!