How would I convert years to date time?

3 次查看(过去 30 天)
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
Stephen23 2022-8-9
编辑:Stephen23 2022-8-9
N = 2022.1765918316;
D = datetime(fix(N),1,1) + calyears([0;1]);
T = D(1) + diff(D)*mod(N,1)
T = datetime
06-Mar-2022 10:56:40

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Dates and Time 的更多信息

标签

产品


版本

R2020b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by