I want to convert the Julian date 273.791667 to calendar day and time
9 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Thishan Dharshana Karandana Gamalathge
le 20 Juil 2017
Commenté : James Tursa
le 20 Juil 2017
I want to convert the Julian date 273.791667 to calandar day and time
1 commentaire
James Tursa
le 20 Juil 2017
Modifié(e) : James Tursa
le 20 Juil 2017
As a nit, that number should be referred to as "day of year" and not "Julian date". I know there are segments of the scientific community that call it a "Julian date", but that usage is confusing at best. E.g., the definition of the term from the USNO:
You will find variations of this term in the literature depending on the underlying time scale (e.g., UT or TT) and 0 point, but even these are not "day of the year" types of measures.
Réponse acceptée
Chad Greene
le 20 Juil 2017
You'll have to specify a year, but for 2017 you can get a date vector like this:
datevec(datenum(2017,0, 273.791667))
or a date string like this:
datestr(datenum(2017,0, 273.791667))
8 commentaires
Thishan Dharshana Karandana Gamalathge
le 20 Juil 2017
Modifié(e) : James Tursa
le 20 Juil 2017
James Tursa
le 20 Juil 2017
datevec returns a vector. You cannot stuff a vector into a single element.
Plus de réponses (1)
Steven Lord
le 20 Juil 2017
Use datetime. You can 'ConvertFrom' 'juliandate' (Number of days since noon UTC 24-Nov-4714 BCE (proleptic Gregorian calendar)) or 'modifiedjuliandate' (Number of days since midnight UTC 17-Nov-1858).
If you want to determine what the 273.791667th day of the year is, try something like this. Check the day of the year using the day function with the 'dayofyear' option:
x = datetime(2017, 1, 0) + days(273.791667)
day(x, 'dayofyear')
2 commentaires
Walter Roberson
le 20 Juil 2017
If you want to specify that this was UTC, you can use
x = datetime(2017, 1, 0, 'TimeZone', 'UTC') + days(273.791667)
and if you then want to see it in local time,
x.TimeZone = 'local'
Note that this is not the same as
x = datetime(2017, 1, 0, 'TimeZone', 'local') + days(273.791667)
In order for the timezone conversion to be done properly, you need to set to UTC first and then change the timezone; if you just set the timezone directly like in this second example then MATLAB will assume that you mean that the given date/time information is being stated relative to your timezone.
Voir également
Catégories
En savoir plus sur Calendar dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!