How would I convert years to date time?

5 vues (au cours des 30 derniers jours)
Ali Almakhmari
Ali Almakhmari le 9 Août 2022
Modifié(e) : Stephen23 le 9 Août 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?

Réponse acceptée

Stephen23
Stephen23 le 9 Août 2022
Modifié(e) : Stephen23 le 9 Août 2022
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

Plus de réponses (0)

Catégories

En savoir plus sur Dates and Time dans Help Center et File Exchange

Produits


Version

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by