gives a string representing the complete current local date and time.


gives the specified element or format for date and time.


concatenates the specified elements in the order given.


gives a string corresponding to a DateList specification.


gives a string corresponding to an AbsoluteTime specification.


gives a string corresponding to a DateObject specification.


gives elements elems of the date or time specification spec.

Details and Options

  • DateString[] by default gives its output in the form specified by $DateStringFormat.
  • The following output elements can be given:
  • "Date"full date
    "DateShort"full date, with short day and month names
    "Time"full time
    "DateTime"full date and time
    "DateTimeShort"full date and time, with short names
    "ISODate"full date conforming to ISO-8601
    "ISOWeekDate"full week date conforming to ISO-8601
    "ISOOrdinalDate"full ordinal date conforming to ISO-8601
    "ISODateTime"full date and time conforming to ISO-8601
    "ADBC"AD or BC
    "CEBCE"CE or BCE
    "Millennium"1000 year period beginning with year XX00
    "Century"100 year period beginning with year XX00
    "Decade"10 year period
    "Year"full year (e.g. 2005)
    "YearShort"2digit year (e.g. 05)
    "ISOYear"year conforming to ISO-8601 (e.g. 0199)
    "YearRomanNumeral"year using Roman numerals
    "YearUnsigned"year without a sign
    "YearExact"year including fraction
    "YearFraction"fractional part of year
    "QuarterName"quarter of year (e.g. "Quarter 1")
    "QuarterNameShort"quarter of year in short form (e.g. "Q1")
    "Quarter"quarter number (e.g. 1)
    "MonthName"month name (e.g. "August")
    "MonthNameShort"month name in short form (e.g. "Aug")
    "MonthNameInitial"first letter of month name (e.g. "A")
    "Month"2digit month number (e.g. 08)
    "MonthShort"1 or 2digit month number (e.g. 8)
    "MonthExact"month including fraction
    "MonthFraction"fractional part of month
    "MonthRomanNumeral"month using Roman numerals
    "MonthRomanNumeralLowerCase"month using lowercase Roman numerals
    "Week"2digit week number (e.g. 02)
    "WeekShort"1 or 2digit week number (e.g. 2)
    "DayName"day of the week (e.g. "Wednesday")
    "DayNameShort"day of the week in short form (e.g. "Wed")
    "DayNameInitial"first letter of day name (e.g. "W")
    "ISOWeekDay"day number of week conforming to ISO-8601 (e.g. 4)
    "Day"2digit day of the month (e.g. 09)
    "DayShort"1 or 2digit day of the month (e.g. 9 or 29)
    "DayExact"day including fraction
    "DayFraction"fractional part of day
    "ISOYearDay"3digit day of the year conforming to ISO-8601 (e.g. 094)
    "ISOYearDayShort"1, 2 or 3digit day of the year (e.g. 94)
    "ISOYearDayExact"year day including fraction
    "ISOYearDayFraction"fractional part of year day
    "Hour"2digit hour based on system preferences
    "Hour12"2digit hour on 12hour clock (e.g. 07)
    "Hour24"2digit hour on 24hour clock (e.g. 19)
    "HourShort"1 or 2digit hour based on system preferences
    "Hour12Short"1 or 2digit hour on 12hour clock (e.g. 7)
    "Hour24Short"1 or 2digit hour on 24hour clock (e.g. 7, 19)
    "HourExact"hour including fraction
    "HourFraction"fractional part of hour
    "AMPM"AM or PM
    "AMPMLowerCase"am or pm
    "TimeZoneGMTRelative"GMT offset (e.g. GMT-04:00)
    "ISOTimeZone"GMT offset conforming to ISO-8601 (e.g. -04:00)
    "TimeZoneName"time zone name (e.g. EST)
    "TimeZoneNameShort"short time zone name (e.g. ET)
    "Minute"2digit minute (e.g. 05)
    "MinuteShort"1 or 2digit minute (e.g. 5 or 35)
    "MinuteExact"minute including fraction
    "MinuteFraction"fractional part of minute
    "Second"2digit seconds
    "SecondShort"1 or 2digit seconds
    "SecondExact"seconds including fractions
    "SecondFraction"fractional part of second
    "Millisecond"3digit milliseconds
    "MillisecondShort"1, 2, or 3digit milliseconds
    "MillisecondExact"millisecond including fraction
    "MillisecondFraction"fractional part of millisecond
  • Any other string given in the list of elements is concatenated literally in the output string.
  • With a typical value for $DateStringFormat, DateString[{y,m,d,h,m,s}] will truncate fractional seconds.
  • Shorter lists can be used in DateString[{y,m,}]: {y} is equivalent to {y,1,1,0,0,0}, {y,m} to {y,m,1,0,0,0}, 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. »
  • In DateString[spec,elems], the following date and time specifications can be given as spec:
  • timeabsolute time specification
    {y,m,d,h,m,s}DateList specification
    "string"DateString output
    {"string",{"e1","e2",}}date string formed from specific elements
  • In the form DateString[{"string",{"e1","e2",},], the "ei" can be "Year", "YearShort", "Quarter", "Month", "MonthName", "Day", "DayName", "Hour", "Hour12", "AMPM", "Minute", or "Second".
  • DateString[{"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 DateString[{"string",{"e1","e2",},], the "ei" are extracted from "string" in the order given, and can be separated by any non-alphanumeric characters. »
  • DateString[{"string",{"e1","sep12","e2","sep23",},] extracts elements using the explicit separators specified. »
  • DateString[date] uses the DateFormat value of the specified DateObject to determine the elements included in the resulting string.
  • In DateString[spec,elems], the time and date corresponding to spec are by default assumed to be in the time zone specified by $TimeZone, unless spec explicitly specifies another time zone.
  • DateString[spec,elems,TimeZone->z] gives output converted to time zone z.
  • DateString[] uses whatever date and time have been set on your computer system. It performs no corrections for time zones, daylight saving time, etc.
  • DateString[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. »


open allclose all

Basic Examples  (4)

Find the current date:

Click for copyable input

The current date in a specific format:

Click for copyable input

Another date in a specific format:

Click for copyable input

DateString supports a number of ISO-8601 date formats:

Click for copyable input
Click for copyable input
Click for copyable input
Click for copyable input

Scope  (9)

Options  (1)

Applications  (1)

Properties & Relations  (6)

Possible Issues  (2)

See Also

DateList  DateObject  DatePlus  DateDifference  AbsoluteTime  $TimeZone  SessionTime  TimeUsed  FileDate  $CreationDate  ToUpperCase  ToLowerCase  DateListPlot  $DateStringFormat

Introduced in 2007