DateString
gives a string representing the complete current local date and time.
DateString["elem"]
gives the specified element or format for date and time.
DateString[{"elem1","elem2",…}]
concatenates the specified elements in the order given.
DateString[{y,m,d,h,m,s}]
gives a string corresponding to a DateList specification.
DateString[time]
gives a string corresponding to an AbsoluteTime specification.
DateString[date]
gives a string corresponding to a DateObject specification.
DateString[spec,elems]
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 date format specifications can be given as elements:
-
"Date" full date Thursday 4 April 2019 "DateShort" short date Thu 4 Apr 2019 "Time" full time 15:57:49 "DateTime" full date and time Thursday 4 April 2019 15:57:57 "DateTimeShort" short date and time Thu 4 Apr 2019 15:58:08 "ISODate" ISO-8601 date 2019-04-04 "ISOWeekDate" ISO week date 2019-W14-4 "ISOOrdinalDate" ISO ordinal date 2019-094 "ISODateTime" ISO date and time 2019-04-04T15:58:57 - Elements related to year include the following:
-
"Year" full year 2005 "YearShort" 2-digit year 05 "YearExact" year with fraction 2005.26 "YearFraction" fractional year 0.256625 "ISOYear" ISO-8601 year 2005 "YearUnsigned" year without sign 2005 "YearRomanNumeral" year in Roman numerals MMV "ADBC" AD or BC AD "CEBCE" CE or BCE BCE - Elements related to month include the following:
-
"Month" 2‐digit month number 08 "MonthShort" 1‐ or 2‐digit month number 8 "MonthExact" month including fraction 8.26759 "MonthFraction" fractional part of month 0.267586 "MonthName" month name August "MonthNameShort" month name in short form Aug "MonthNameInitial" first letter of month name A "MonthRomanNumeral" month in Roman numerals VIII "MonthRomanNumeralLowerCase" lowercase Roman numerals viii - Elements related to day of the month include the following:
-
"Day" 2‐digit day of the month 09 "DayShort" 1‐ or 2‐digit day 9 "DayExact" day including fraction 9.29518 "DayFraction" fractional part of day 0.295176 - Elements related to day of the week include the following:
-
"DayName" day of the week Wednesday "DayNameShort" short day of the week Wed "DayNameInitial" first letter of day name W "ISOWeekDay" ISO-8601 day number 4 "ISOWeekDayExact" day number with fraction 4.29518 "ISOWeekDayFraction" fractional day number 0.295176 - Elements related to hour include the following:
-
"Hour" - 2‐digit hour
19 "Hour12" 2-digit 12-hour clock 07 "Hour24" 2-digit 24-hour clock 19 "HourShort" 1- or 2-digit hour 19 "Hour12Short" 1- or 2-digit 12-hour clock 7 "Hour24Short" 1- or 2-digit 24-hour clock 19 "HourExact" hour including fraction 7.08422 "HourFraction" fractional part of hour 0.0842222 "AMPM" AM or PM PM "AMPMLowerCase" am or pm pm - Elements related to minute include the following:
-
"Minute" 2-digit minute 05 "MinuteShort" 1- or 2-digit minute 5 "MinuteExact" minute including fraction 5.05333 "MinuteFraction" fractional part of minute 0.0533333 - Elements related to second include the following:
-
"Second" 2‐digit seconds 03 "SecondShort" 1‐ or 2‐digit seconds 3 "SecondExact" seconds including fractions 03.199 "SecondFraction" fractional part of second 0.2 "Millisecond" 3‐digit milliseconds 019 "MillisecondShort" 1‐, 2‐, or 3‐digit milliseconds 19 "MillisecondExact" millisecond with fraction 019.99 "MillisecondFraction" fractional part of millisecond 0.999809 - Elements larger than a year include the following:
-
"Millennium" beginning with year X000 -3000 "MillenniumUnsigned" unsigned millennium 3000 "MillenniumBeginning01" beginning with year X001 2001 "Century" beginning with year XX00 -2100 "CenturyUnsigned" unsigned century 2100 "CenturyBeginning01" beginning with year XX01 2001 "Decade" 10 year period -2010 "DecadeUnsigned" unsigned decade 2010 - Elements related to multiple date elements include the following:
-
"Quarter" quarter number 1 "QuarterName" quarter of year Quarter 1 "QuarterNameShort" quarter of year in short form Q1 "Week" 2‐digit week number 02 "WeekShort" 1- or 2‐digit week number 2 "WeekExact" week including fraction 2.44048 "WeekFraction" fractional week number 0.440478 - Additional ISO-8601 date elements include the following:
-
"ISOYearDay" 3‐digit day of the year 094 "ISOYearDayShort" 1‐, 2‐ or 3‐digit day of year 94 "ISOYearDayExact" year day including fraction 94.295 "ISOYearDayFraction" fractional part of year day 0.295176 - Elements related to time zone include the following:
-
"TimeZoneGMTRelative" GMT offset GMT-04:00 "ISOTimeZone" ISO-8601 GMT offset -04:00 "TimeZoneName" time zone name Eastern Standard Time "TimeZoneNameShort" short time zone name EST - 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:
-
time absolute 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. »
- For "*Exact" elements (such as "SecondExact" and "MonthExact"), the integer part of the returned value will match the value given by the normal element (i.e. "Second" and "Month").
- 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. »
Examples
open allclose allBasic Examples (4)
The current date in a specific format:
Another date in a specific format:
DateString supports a number of ISO-8601 date formats:
Scope (9)
Find the day of the week corresponding to a date:
Date lists are converted to standard normalized form:
Strings are automatically interpreted when possible:
Both DateObject and TimeObject expressions include default DateFormat values:
Separators for input strings are assumed if not specified:
Give explicit separators for an input date string:
Day, hour, minute, and second values can be nonintegers:
Options (1)
Properties & Relations (6)
DateObject represents a given date:
AbsoluteTime represents dates as seconds since the beginning of 1900:
DateList represents dates as lists of date elements:
DateString represents dates as strings:
Use $DateStringFormat to define the output formatting:
DateString gives results that match a DatePattern:
Use DateListPlot to plot data with date string coordinates:
Use DatePlus to add time units to a date string:
Use DateDifference to find the number of time units between dates:
Possible Issues (3)
Explicit elements may be needed to interpret ambiguous strings:

For numeric TimeZone values, the elements "TimeZoneName" and "TimeZoneNameShort" are returned as GMT offsets:
When using a named TimeZone, an appropriate "TimeZoneName" will be returned:
The element "WeekExact" uses the same integer part as "Week" and thus will never return a value smaller than 1:
Text
Wolfram Research (2007), DateString, Wolfram Language function, https://reference.wolfram.com/language/ref/DateString.html (updated 2019).
BibTeX
BibLaTeX
CMS
Wolfram Language. 2007. "DateString." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2019. https://reference.wolfram.com/language/ref/DateString.html.
APA
Wolfram Language. (2007). DateString. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/DateString.html