DateList

DateList[]
gives the current local date and time in the form .

DateList[time]
gives a date list corresponding to an AbsoluteTime specification.

DateList[{y, m, d, h, m, s}]
converts a date list to standard normalized form.

DateList["string"]
converts a date string to a date list.

DateList[{"string", {"e1", "e2", ...}}]
gives the date list obtained by extracting elements from .

Details and OptionsDetails and Options

  • DateList[] uses whatever date and time have been set on your computer system. It performs no corrections for time zones, daylight saving time, etc.
  • DateList[TimeZone->z] gives the date and time inferred for time zone z by assuming that your computer is set for the time zone specified by $TimeZone. »
  • All values returned by DateList[] are integers, except the number of seconds. The number of seconds is never more accurate than $TimeUnit.
  • Shorter lists can be used in DateList[{y, m, ...}]: {y} is equivalent to , to , etc.
  • Values of m, d, h, m, s outside their normal ranges are appropriately reduced. Noninteger values of d, h, m, s can also be used. »
  • You can compare two lists returned by DateList using Order. »
  • In the form DateList[{"string", {"e1", "e2", ...}}] the can be , , , , , , , , , , , , or .
  • DateList[{"string", {"e1", "e2", ...}}] uses the to fill in elements of . Those not filled in are taken to have default values , where is the current year. »
  • In DateList[{"string", {"e1", "e2", ...}}], the are extracted from in the order given, and can be separated by any non-alphanumeric characters. »
  • DateList[{"string", {"e1", "sep12", "e2", "sep23", ...}}] extracts elements using the explicit separators specified. »

ExamplesExamplesopen allclose all

Basic Examples (5)Basic Examples (5)

Find the current date:

In[1]:=
Click for copyable input
Out[1]=

Convert an absolute time to a date list:

In[1]:=
Click for copyable input
Out[1]=

Expand an elided date list:

In[1]:=
Click for copyable input
Out[1]=

Convert a date string to a date list:

In[1]:=
Click for copyable input
Out[1]=

Specify date elements for converting a string:

In[1]:=
Click for copyable input
Out[1]=
New in 6
New to Mathematica? Find your learning path »
Have a question? Ask support »