juliandate

Convert MATLAB datetime to Julian date

Description

example

d = juliandate(t) returns the Julian dates equivalent to the datetime values in t.

  • If the time zone of t is not specified, then juliandate treats the times in t as UTC times. This interpretation might differ from your treatment of “unzoned” datetime arrays in other contexts. For example, you might think of datetime('now') as returning your local time. However, juliandate interprets it as a UTC time.

  • If the time zone of t is specified, then juliandate uses the offset for the time zone to compute Julian dates with respect to UTC.

  • juliandate ignores leap seconds unless the time zone of t is UTCLeapSeconds.

The best practice is to specify the time zone of t before calling juliandate.

d = juliandate(t,dateType) returns the type of Julian dates specified by dateType. For example, you can convert datetime values to modified Julian dates.

Examples

collapse all

Create datetime values and convert them to the equivalent Julian dates. Show the differences in Julian dates between zoned and unzoned datetime values. The best practice is to specify a time zone for a datetime array before calling juliandate.

Create a datetime array and specify its time zone.

t1 = datetime('2016-07-29 10:05:24') + calmonths(1:3);
t1.TimeZone = 'America/New_York'
t1 = 1x3 datetime
   29-Aug-2016 10:05:24   29-Sep-2016 10:05:24   29-Oct-2016 10:05:24

Convert t1 to the equivalent Julian dates. juliandate accounts for the time zone offset when it computes Julian dates.

format longG
jd1 = juliandate(t1)
jd1 = 1×3

          2457630.08708333          2457661.08708333          2457691.08708333

Create a datetime array with the same values as t1, but with no time zone. Convert it to the equivalent Julian dates. juliandate treats the times in t2 as UTC times, with no time zone offset.

t2 = datetime('2016-07-29 10:05:24') + calmonths(1:3);
jd2 = juliandate(t2)
jd2 = 1×3

          2457629.92041667          2457660.92041667          2457690.92041667

Show the differences between jd2 and jd1. The differences are equal to the time offset, in days, between UTC and the time zone of jd1.

jd2 - jd1
ans = 1×3

        -0.166666666511446        -0.166666666511446        -0.166666666511446

Input Arguments

collapse all

Input date and time, specified as a datetime array.

Type of Julian date values, specified as either 'juliandate' or 'modifiedjuliandate'.

  • If dateType is 'juliandate', then juliandate converts the datetime values in t to the equivalent Julian dates. A Julian date is the number of days and fractional days since noon on November 24, 4714 BCE in the proleptic Gregorian calendar, or January 1, 4713 BCE in the proleptic Julian calendar.

  • If dateType is 'modifiedjuliandate', then juliandate converts the datetime values in t to the equivalent modified Julian dates. A modified Julian date is the number of days and fractional days since November 17, 1858 00:00:00.

More About

collapse all

Julian dates

A Julian date is the number of days and fractional days since noon on November 24, 4714 BCE in the proleptic Gregorian calendar, or January 1, 4713 BCE in the proleptic Julian calendar.

Extended Capabilities

Introduced in R2014b