Convert Zoned and Unzoned Datetime Values to Julian Dates
A Julian date is the number of days (including fractional days) since noon on November 24, 4714
BCE, in the proleptic Gregorian calendar, or January 1, 4713 BCE, in the proleptic Julian calendar. To
convert datetime arrays to Julian dates, use the juliandate function.
Create a datetime array and specify its time zone.
DZ = datetime('2016-07-29 10:05:24') + calmonths(1:3);
DZ.TimeZone = 'America/New_York'
DZ = 1x3 datetime
29-Aug-2016 10:05:24
29-Sep-2016 10:05:24
29-Oct-2016 10:05:24
Convert D to the equivalent Julian dates.
format longG
JDZ = juliandate(DZ)
JDZ = 1×3
2.4576
2.4577
2.4577
Create an unzoned copy of DZ. Convert D to the equivalent Julian dates. As D has no time zone,
juliandate treats the times as UTC times.
D = DZ;
D.TimeZone = '';
JD = juliandate(D)
JD = 1×3
2.4576
2.4577
2.4577
Compare JDZ and JD. The differences are equal to the time zone offset between UTC and the
America/New_York time zone in fractional days.
JDZ - JD
ans = 1×3
0.1667
0.1667
0.1667
Convert Zoned and Unzoned Datetime Values to POSIX Times
The POSIX time is the number of seconds (including fractional seconds) elapsed since 00:00:00 1Jan-1970 UTC (Universal Coordinated Time), ignoring leap seconds. To convert datetime arrays to
POSIX times, use the posixtime function.
Create a datetime array and specify its time zone.
DZ = datetime('2016-07-29 10:05:24') + calmonths(1:3);
DZ.TimeZone = 'America/New_York'
7 Dates and Time
7-8
A Julian date is the number of days (including fractional days) since noon on November 24, 4714
BCE, in the proleptic Gregorian calendar, or January 1, 4713 BCE, in the proleptic Julian calendar. To
convert datetime arrays to Julian dates, use the juliandate function.
Create a datetime array and specify its time zone.
DZ = datetime('2016-07-29 10:05:24') + calmonths(1:3);
DZ.TimeZone = 'America/New_York'
DZ = 1x3 datetime
29-Aug-2016 10:05:24
29-Sep-2016 10:05:24
29-Oct-2016 10:05:24
Convert D to the equivalent Julian dates.
format longG
JDZ = juliandate(DZ)
JDZ = 1×3
2.4576
2.4577
2.4577
Create an unzoned copy of DZ. Convert D to the equivalent Julian dates. As D has no time zone,
juliandate treats the times as UTC times.
D = DZ;
D.TimeZone = '';
JD = juliandate(D)
JD = 1×3
2.4576
2.4577
2.4577
Compare JDZ and JD. The differences are equal to the time zone offset between UTC and the
America/New_York time zone in fractional days.
JDZ - JD
ans = 1×3
0.1667
0.1667
0.1667
Convert Zoned and Unzoned Datetime Values to POSIX Times
The POSIX time is the number of seconds (including fractional seconds) elapsed since 00:00:00 1Jan-1970 UTC (Universal Coordinated Time), ignoring leap seconds. To convert datetime arrays to
POSIX times, use the posixtime function.
Create a datetime array and specify its time zone.
DZ = datetime('2016-07-29 10:05:24') + calmonths(1:3);
DZ.TimeZone = 'America/New_York'
7 Dates and Time
7-8
