({{, (RefLink[DateObject, paclet:ref/DateObject])[] 
gives the current local date.}, {, (RefLink[DateObject, paclet:ref/DateObject])[{y,m,d,h,m,s}]
gives a date object of standard normalized form.}, {, (RefLink[DateObject, paclet:ref/DateObject])["string"]
converts a date string to a date object.}, {, (RefLink[DateObject, paclet:ref/DateObject])[{"string",{"(Subscript[e, 1])","(Subscript[e, 2])", …}}]
gives the date object obtained by extracting elements "(Subscript[e, i])" from "string".}, {, (RefLink[DateObject, paclet:ref/DateObject])[rdate,gran]
gives the date object of calendar granularity gran that includes the reference date rdate.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[DateObject, paclet:ref/DateObject])[] uses whatever date and time have been set on your computer system by default.

Values of m, d, h, m, s outside their normal ranges are appropriately reduced. Noninteger values of d, h, m, and s can also be used.

In the form (RefLink[DateObject, paclet:ref/DateObject])[{"string",{"(Subscript[e, 1])","(Subscript[e, 2])",…}}], the "(Subscript[e, i])" can be "Year", "YearShort", "Quarter", "Month", "MonthName", "Day", "DayName", "Hour", "Hour12", "AMPM", "Minute", "Second", or "Millisecond".

(RefLink[DateObject, paclet:ref/DateObject])[{"string",{"(Subscript[e, 1])","(Subscript[e, 2])",…}}] uses the "(Subscript[e, i])" to fill in elements of {y,m,d,h,m,s}. Those not filled in are taken to have default values {(Subscript[y, c]),1,1,0,0,0}, where (Subscript[y, c]) is the current year.

In (RefLink[DateObject, paclet:ref/DateObject])[{"string",{"(Subscript[e, 1])","(Subscript[e, 2])",…}}], the "(Subscript[e, i])" are extracted from "string" in the order given, and can be separated by any non-alphanumeric characters.

(RefLink[DateObject, paclet:ref/DateObject])[{"string",{"(Subscript[e, 1])","(Subscript[sep, 12])","(Subscript[e, 2])","(Subscript[sep, 23])",…}}] extracts elements using the explicit separators specified.

(RefLink[DateObject, paclet:ref/DateObject])[time] gives a date object corresponding to an (RefLink[AbsoluteTime, paclet:ref/AbsoluteTime]) specification.

For an image with Exif date time information, (RefLink[DateObject, paclet:ref/DateObject])[image] returns that information as a standard (RefLink[DateObject, paclet:ref/DateObject]) expression.

(RefLink[DateObject, paclet:ref/DateObject])[rdate,gran] represents a discrete calendar element of granularity gran for the reference date rdate. For example, (RefLink[DateObject, paclet:ref/DateObject])[{2017,1,16},"Week"] represents the week beginning Monday, January 16, 2017.

(RefLink[DateObject, paclet:ref/DateObject])[rdate,gran] will normalize to the canonical representation of the (RefLink[DateObject, paclet:ref/DateObject]) for that granularity. For example, (RefLink[DateObject, paclet:ref/DateObject])[{2016},"Decade"] will canonicalize to (RefLink[DateObject, paclet:ref/DateObject])[{2010},"Decade"].

In (RefLink[DateObject, paclet:ref/DateObject])[rdate,gran], the calendar granularity gran can be any of the following:

(RefLink[DateObject, paclet:ref/DateObject])[rdate,"MidpointInstant"] can be used to construct a (RefLink[DateObject, paclet:ref/DateObject]) with granularity "Instant" with a reference date at the mid-point of rdate.

(RefLink[DateObject, paclet:ref/DateObject])[list] is taken to represent a date with granularity as follows:

(RefLink[DateObject, paclet:ref/DateObject])["string"] is taken to represent a date with granularity inferred from the information given in the string.

The following options can be given:

Possible (RefLink[CalendarType, paclet:ref/CalendarType]) specifications are: (RefLink[Automatic, paclet:ref/Automatic]), "Gregorian", "Julian", "Jewish", and "Islamic".

The default value of (RefLink[CalendarType, paclet:ref/CalendarType]) is (RefLink[Automatic, paclet:ref/Automatic]), which uses the proleptic Gregorian calendar in which there is no year 0. Years prior to the Common Era are negative, and those after are positive.

(RefLink[TimeZone, paclet:ref/TimeZone]) specifications should be a numerical offset from GMT, a time zone string, (RefLink[None, paclet:ref/None]) or a geo entity location.

With a typical value for (RefLink[$DateStringFormat, paclet:ref/$DateStringFormat]), the display of (RefLink[DateObject, paclet:ref/DateObject])[{y,m,d,h,m,s}] will truncate fractional seconds.

(RefLink[DateObject, paclet:ref/DateObject]) allows addition and subtraction of time quantities.

Subtracting two (RefLink[DateObject, paclet:ref/DateObject]) expressions yields a time quantity.

Functions such as (RefLink[Sort, paclet:ref/Sort]), (RefLink[Greater, paclet:ref/Greater]), (RefLink[Max, paclet:ref/Max]), etc. work with (RefLink[DateObject, paclet:ref/DateObject]).

(RefLink[Information, paclet:ref/Information]) for a (RefLink[DateObject, paclet:ref/DateObject]) may include the following properties:

OpenersPrimaryExamplesSection(Spacer1)Examples  (25)

OpenersExampleSection0(Spacer1)Basic Examples  (6)

Find the current date:

DateObject[]

Date object expression representing the year 2015:

DateObject[{2015}]

Date object representing the week beginning Monday, August 1, 2016:

DateObject[{2016,8,1}, "Week"]

Convert an absolute time to a date object:

DateObject[3155673600]

Represent a specific year and month:

DateObject[{2006,12}]

Or represent just a year:

DateObject[{1985}]

Add 1000 weeks to a date:

DateObject[{1988,6,23}]+LinguisticAssistant

Subtract two dates to get a time quantity:

DateObject[{2009,5,18}]-DateObject[{1988,6,23}]

OpenersExampleSection1(Spacer1)Scope  (6)

Date objects are interpreted using their standard normalized form:

DateObject[{2006,2,31}]

This includes normalization for values preceding the first day of the year:

DateObject[{2015, 0, 0}]

Strings are automatically interpreted when possible:

DateObject["2006 12-15"]

DateObject["foo"]

(RefLink[DateObject, paclet:ref/DateObject]) automatically chooses the first date compatible with the input information:

DateObject[{2016},"Day"]

DateObject[Today,"Minute"]

Date objects including additional elements beyond what are required for a given calendar granularity will be automatically normalized to their canonical form:

DateObject[{2016,4,3},"Year"]

Combine a (RefLink[DateObject, paclet:ref/DateObject]) and a (RefLink[TimeObject, paclet:ref/TimeObject]) into a single expression:

d=Today;
t=TimeObject[{13,0,2}];

DateObject[d,t]

Date and time of an image:

DateObject[]

OpenersExampleSection2(Spacer1)Options  (5)

OpenersExampleSubsection0(Spacer1)CalendarType  (2)

Find the current date on the Jewish calendar:

DateObject[CalendarType->"Jewish"]

Represent a date on the Islamic calendar:

DateObject[{1435, 1, 1}, CalendarType -> "Islamic"]

OpenersExampleSubsection1(Spacer1)DateFormat  (2)

Use long date format:

DateObject[]

Specify your own format:

DateObject[DateFormat->{"Day","/","Month","/","Year"}]

DateObject[DateFormat->{"Hour",":","Minute"," (on ","Month","/","Day",")"}]

OpenersExampleSubsection2(Spacer1)TimeZone  (1)

Find the current date in Greenwich, United Kingdom:

DateObject[TimeZone->0]

Specify no time zone for a date object:

DateObject[{2012,8,4},TimeZone->None]

Represent 11am Eastern Standard Time on March 3, 2001:

DateObject[{2001,3,3},TimeObject[{11}],TimeZone->"America/New_York"]

(RefLink[TimeZone, paclet:ref/TimeZone]) specifications can be used with all supported calendar types:

DateObject[{5774,11,3},TimeObject[{13,50,2}],CalendarType->"Jewish",TimeZone->2]

OpenersExampleSection3(Spacer1)Properties & Relations  (8)

(RefLink[AbsoluteTime, paclet:ref/AbsoluteTime]) represents dates as seconds since the beginning of 1900:

AbsoluteTime[DateObject[]]

(RefLink[DateList, paclet:ref/DateList]) represents dates as lists of date elements:

DateList[DateObject[{2007}]]

(RefLink[DateString, paclet:ref/DateString]) represents dates as strings:

DateString[Today]

(RefLink[DateValue, paclet:ref/DateValue]) can be used to extract a granular date:

DateValue[Today,"Year",DateObject]

Arithmetic using date objects returns units in the coarsest granularity of the dates:

Today-DateObject[{2010}]

Now-Today

Granular (RefLink[DateObject, paclet:ref/DateObject]) expressions with different time zones within the same calendar granularity are considered (RefLink[Equal, paclet:ref/Equal]):

DateObject[{2017, 2, 1}, "Day", TimeZone-> -6] == DateObject[{2017, 2, 1}, "Day", TimeZone -> 0]

But are not (RefLink[SameQ, paclet:ref/SameQ]):

DateObject[{2017, 2, 1}, "Day", TimeZone-> -6] ===DateObject[{2017, 2, 1}, "Day", TimeZone -> 0]

Compare date objects to determine their sequence of occurrence:

Today>(DateObject["Day: ""Thu 4 Jan 2001", DateObject[{2001,1,4},"Day","Gregorian",-6.`]])

(DateObject["Day: ""Mon 8 Jan 2001", DateObject[{2001,1,8},"Day","Gregorian",-6.`]])>(DateObject["Day: ""Wed 10 Jan 2001", DateObject[{2001,1,10},"Day","Gregorian",-6.`]])

(DateObject["Hour: ""Thu 1 Aug 2013 05 pm""GMT"-6.`, DateObject[{2013,8,1,17},"Hour","Gregorian",-6.`]])==(DateObject["Hour: ""Thu 1 Aug 2013 06 pm""GMT"-5.`, DateObject[{2013,8,1,18},"Hour","Gregorian",-5.`]])

Sort[{(DateObject["Day: ""Wed 1 Aug 2001", DateObject[{2001,8,1},"Day","Gregorian",-6.`]]),(DateObject["Day: ""Fri 12 Mar 2010", DateObject[{2010,3,12},"Day","Gregorian",-6.`]]),(DateObject["Day: ""Wed 20 Dec 1995", DateObject[{1995,12,20},"Day","Gregorian",-6.`]])}]

(RefLink[GreaterThan, paclet:ref/GreaterThan]), (RefLink[LessThan, paclet:ref/LessThan]) and related test functions also work with (RefLink[DateObject, paclet:ref/DateObject]) expressions:

GreaterThan[Today][Tomorrow]

LessThan[Tomorrow][Now]

Comparisons of date objects with unequal precision and overlapping time periods will return unevaluated:

(DateObject["Month: ""Jan 2001", DateObject[{2001,1},"Month","Gregorian",-6.`]])>(DateObject["Day: ""Thu 4 Jan 2001", DateObject[{2001,1,4},"Day","Gregorian",-6.`]])

(DateObject["Day: ""Mon 1 Jan 2001", DateObject[{2001,1,1},"Day","Gregorian",-6.`]])>(DateObject["Day: ""Thu 4 Jan 2001", DateObject[{2001,1,4},"Day","Gregorian",-6.`]])

(DateObject["Month: ""Jan 2000", DateObject[{2000,1},"Month","Gregorian",-6.`]])>(DateObject["Day: ""Thu 4 Jan 2001", DateObject[{2001,1,4},"Day","Gregorian",-6.`]])

Use (RefLink[Max, paclet:ref/Max]) to find the latest date in a list:

Max[{(DateObject["Year: ""1980", DateObject[{1980},"Year","Gregorian",-6.`]]),(DateObject["Year: ""1995", DateObject[{1995},"Year","Gregorian",-6.`]]),(DateObject["Year: ""2012", DateObject[{2012},"Year","Gregorian",-6.`]])}]

(RefLink[Sort, paclet:ref/Sort]) will arrange dates in sequence:

Sort[{(DateObject["Day: ""Wed 25 Feb 2015", DateObject[{2015,2,25},"Day","Gregorian",-6.`]]),(DateObject["Day: ""Thu 26 Feb 2015", DateObject[{2015,2,26},"Day","Gregorian",-6.`]]),(DateObject["Day: ""Tue 24 Feb 2015", DateObject[{2015,2,24},"Day","Gregorian",-6.`]])}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[TimeObject, paclet:ref/TimeObject])  ▪  (RefLink[Now, paclet:ref/Now])  ▪  (RefLink[DateValue, paclet:ref/DateValue])  ▪  (RefLink[TimeZoneConvert, paclet:ref/TimeZoneConvert])  ▪  (RefLink[CalendarConvert, paclet:ref/CalendarConvert])  ▪  (RefLink[DateDifference, paclet:ref/DateDifference])  ▪  (RefLink[DateString, paclet:ref/DateString])  ▪  (RefLink[DateList, paclet:ref/DateList])  ▪  (RefLink[AbsoluteTime, paclet:ref/AbsoluteTime])  ▪  (RefLink[UnixTime, paclet:ref/UnixTime])  ▪  (RefLink[FromUnixTime, paclet:ref/FromUnixTime])  ▪  (RefLink[JulianDate, paclet:ref/JulianDate])  ▪  (RefLink[FromJulianDate, paclet:ref/FromJulianDate])  ▪  (RefLink[TimeSeries, paclet:ref/TimeSeries])  ▪  (RefLink[EventSeries, paclet:ref/EventSeries])  ▪  (RefLink[CurrentDate, paclet:ref/CurrentDate])  ▪  (RefLink[DayRound, paclet:ref/DayRound])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Date & Time, paclet:guide/DateAndTime])}, {▪(RefLinkPlain[Time Series Processing, paclet:guide/TimeSeries])}, {▪(RefLinkPlain[Free-Form & External Input, paclet:guide/FreeFormAndExternalInput])}, {▪(RefLinkPlain[Weather Data, paclet:guide/WeatherData])}, {▪(RefLinkPlain[People & History, paclet:guide/PeopleAndHistory])}, {▪(RefLinkPlain[Financial Computation, paclet:guide/Finance])}, {▪(RefLinkPlain[Scientific Data Analysis, paclet:guide/ScientificDataAnalysis])}, {▪(RefLinkPlain[Database Connectivity, paclet:guide/DatabaseConnectivity])}, {▪(RefLinkPlain[WDF (Wolfram Data Framework), paclet:guide/WDFWolframDataFramework])}, {▪(RefLinkPlain[Knowledge Representation & Access, paclet:guide/KnowledgeRepresentationAndAccess])}})}})

({{(Spacer1), ({{(Spacer1)Related Links}, {(WebLink[DocumentationFooterIconsRelatedLinks-EIWL.png(Spacer1)An Elementary Introduction to the Wolfram Language, https://www.wolfram.com/language/elementary-introduction/19-dates-and-times.html])(WebLink[: Dates and Times, https://www.wolfram.com/language/elementary-introduction/19-dates-and-times.html])}})}})