Wolfram Language & System 11.0 (2016)|Legacy Documentation

This is documentation for an earlier version of the Wolfram Language.View current documentation (Version 11.2)


represents the current local date.

represents the specified date list and TimeObject time.

gives a date object corresponding to an AbsoluteTime specification.

represents a date object of standard normalized form.

converts a date string to a date object.

DateObject[{"string",{"e1","e2", }}]
gives the date object obtained by extracting elements "ei" from "string".

Details and OptionsDetails and Options

  • DateObject[] uses whatever date and time have been set on your computer system by default.
  • DateObject[{y,m,d,h,m,s}] is canonicalized to DateObject[{y,m,d},TimeObject[{h,m,s}], where values of m, d, h, m, s outside their normal ranges are appropriately reduced.
  • Shorter lists can be used in DateObject[{y,m,}], which represents the date to whatever accuracy is specified: {y} is not treated as being equivalent to {y,1,1,0,0,0}.
  • In the form DateObject[{"string",{"e1","e2",}}], the "ei" can be "Year", "YearShort", "Quarter", "Month", "MonthName", "Day", "DayName", "Hour", "Hour12", "AMPM", "Minute", "Second", or "Millisecond".
  • DateObject[{"string",{"e1","e2",}}] uses the "ei" to fill in elements of {y,m,d,h,m,s}. Those not filled in are taken to have default values {yc,1,1,0,0,0}, where yc is the current year.
  • In DateObject[{"string",{"e1","e2",}}], the "ei" are extracted from "string" in the order given, and can be separated by any non-alphanumeric characters.
  • DateObject[{"string",{"e1","sep12","e2","sep23",}}] extracts elements using the explicit separators specified.
  • DateObject allows addition and subtraction of time quantities.
  • Subtracting two DateObject constructs yields a time quantity.
  • The following options can be given:
  • CalendarTypeAutomaticcalendar system being used
    DateFormat$DateStringFormatformat used to display date
    TimeZone$TimeZonetime zone being used
  • Possible CalendarType specifications are: Automatic, "Gregorian", "Julian", "Jewish", and "Islamic".
  • The default value of CalendarType is 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.
  • TimeZone specifications should be a numerical offset from GMT or a time zone string.
  • With a typical value for $DateStringFormat, the display of DateObject[{y,m,d,h,m,s}] will truncate fractional seconds.
  • For an image with Exif date time information, DateObject[image] returns that information as a DateObject[date,time}] object.
  • Functions such as Sort, Greater, Max, etc. work with DateObject.

ExamplesExamplesopen allclose all

Basic Examples  (4)Basic Examples  (4)

Find the current date:

Click for copyable input

Convert an absolute time to a date object:

Click for copyable input

Represent a specific year and month:

Click for copyable input

Or represent just a year:

Click for copyable input

Add 1000 weeks to a date:

Click for copyable input

Subtract two dates to get a time quantity:

Click for copyable input
Introduced in 2014
| Updated in 2016