DATE(1P)
π DATE(1P) π β write the date and time
okay bestie, welcome to the POSIX Programmer's Manual π«Ά this page is literally called date, and yes, the Linux implementation of this interface may differ (so go check the corresponding Linux manual page for the deets on Linux behavior), or β plot twist β the interface may not even be implemented on Linux. π
β¨ PROLOG β¨
This manual page is part of the POSIX Programmer's Manual. The Linux implementation of this interface may differ (consult the corresponding Linux manual page for details of Linux behavior), or the interface may not be implemented on Linux. π
πΈ NAME πΈ
date β write the date and time β°
π SYNOPSIS π
date [-u] [+format]
date [-u] mmddhhmm[[cc]yy]
π¦ DESCRIPTION π¦
So like, the date utility shall write the date and time to standard output, or it shall attempt to set the system date and time. π₯ By default, the current date and time shall be written. But if an operand beginning with + is specified, then the output format of date shall be controlled by the conversion specifications and other text in that operand. It's giving customizable, fr fr.
β¨ OPTIONS β¨
The date utility shall conform to the Base Definitions volume of POSIX.1β2017, Section 12.2, Utility Syntax Guidelines. π―
The following option shall be supported:
-uβ Perform operations as if theTZenvironment variable was set to the string"UTC0", or its equivalent historical value of"GMT0". Otherwise,dateshall use the timezone indicated by theTZenvironment variable, or the system default if that variable is unset or null. π
π OPERANDS π
The following operands shall be supported:
+formatβ When the format is specified, each conversion specifier shall be replaced in the standard output by its corresponding value. All other characters shall be copied to the output without change. The output shall always be terminated with a<newline>. π
π Conversion Specifications π
%aβ Locale's abbreviated weekday name.%Aβ Locale's full weekday name.%bβ Locale's abbreviated month name.%Bβ Locale's full month name.%cβ Locale's appropriate date and time representation.%Cβ Century (a year divided by 100 and truncated to an integer) as a decimal number[00,99].%dβ Day of the month as a decimal number[01,31].%Dβ Date in the formatmm/dd/yy.%eβ Day of the month as a decimal number[1,31]in a two-digit field with leading<space>character fill.%hβ A synonym for%b.%Hβ Hour (24-hour clock) as a decimal number[00,23].%Iβ Hour (12-hour clock) as a decimal number[01,12].%jβ Day of the year as a decimal number[001,366].%mβ Month as a decimal number[01,12].%Mβ Minute as a decimal number[00,59].%nβ A<newline>.%pβ Locale's equivalent of either AM or PM.%rβ 12-hour clock time[01,12]using the AM/PM notation; in the POSIX locale, this shall be equivalent to%I:%M:%S %p.%Sβ Seconds as a decimal number[00,60].%tβ A<tab>.%Tβ 24-hour clock time[00,23]in the formatHH:MM:SS.%uβ Weekday as a decimal number[1,7](1=Monday).%Uβ Week of the year (Sunday as the first day of the week) as a decimal number[00,53]. All days in a new year preceding the first Sunday shall be considered to be in week 0.%Vβ Week of the year (Monday as the first day of the week) as a decimal number[01,53]. If the week containing January 1 has four or more days in the new year, then it shall be considered week 1; otherwise, it shall be the last week of the previous year, and the next week shall be week 1.%wβ Weekday as a decimal number[0,6](0=Sunday).%Wβ Week of the year (Monday as the first day of the week) as a decimal number[00,53]. All days in a new year preceding the first Monday shall be considered to be in week 0.%xβ Locale's appropriate date representation.%Xβ Locale's appropriate time representation.%yβ Year within century[00,99].%Yβ Year with century as a decimal number.%Zβ Timezone name, or no characters if no timezone is determinable.%%β A<percent-sign>character.
btw see the Base Definitions volume of POSIX.1β2017, Section 7.3.5, LC_TIME for the conversion specifier values in the POSIX locale. π
π§ Modified Conversion Specifications π§
Some conversion specifiers can be modified by the E and O modifier characters to indicate a different format or specification, as specified in the LC_TIME locale description (see the Base Definitions volume of POSIX.1β2017, Section 7.3.5, LC_TIME). And like, if the corresponding keyword (see era, era_year, era_d_fmt, and alt_digits in the Base Definitions volume of POSIX.1β2017, Section 7.3.5, LC_TIME) is not specified or not supported for the current locale, then the unmodified conversion specifier value shall be used. π
%Ecβ Locale's alternative appropriate date and time representation.%ECβ The name of the base year (period) in the locale's alternative representation.%Exβ Locale's alternative date representation.%EXβ Locale's alternative time representation.%Eyβ Offset from%EC(year only) in the locale's alternative representation.%EYβ Full alternative year representation.%Odβ Day of month using the locale's alternative numeric symbols.%Oeβ Day of month using the locale's alternative numeric symbols.%OHβ Hour (24-hour clock) using the locale's alternative numeric symbols.%OIβ Hour (12-hour clock) using the locale's alternative numeric symbols.%Omβ Month using the locale's alternative numeric symbols.%OMβ Minutes using the locale's alternative numeric symbols.%OSβ Seconds using the locale's alternative numeric symbols.%Ouβ Weekday as a number in the locale's alternative representation (Monday = 1).%OUβ Week number of the year (Sunday as the first day of the week) using the locale's alternative numeric symbols.%OVβ Week number of the year (Monday as the first day of the week, rules corresponding to%V), using the locale's alternative numeric symbols.%Owβ Weekday as a number in the locale's alternative representation (Sunday = 0).%OWβ Week number of the year (Monday as the first day of the week) using the locale's alternative numeric symbols.%Oyβ Year (offset from%C) in alternative representation.
π mmddhhmm[[cc]yy] π
Attempt to set the system date and time from the value given in the operand. This is only possible if the user has appropriate privileges and the system permits the setting of the system date and time. π¨
Here's the breakdown bestie:
- the first
mmis the month (number) ddis the day (number)hhis the hour (number, 24-hour system)- the second
mmis the minute (number) ccis the century and is the first two digits of the year (this is optional)yyis the last two digits of the year and is optional
If century is not specified, then values in the range [69,99] shall refer to years 1969 to 1999 inclusive, and values in the range [00,68] shall refer to years 2000 to 2068 inclusive. The current year is the default if yy is omitted. π
Note: It is expected that in a future version of this standard the default century inferred from a 2-digit year will change. (This would apply to all commands accepting a 2-digit year as input.) β οΈ
π STDIN π
Not used. π
π INPUT FILES π
None. π
π ENVIRONMENT VARIABLES π
The following environment variables shall affect the execution of date:
LANGβ Provide a default value for the internationalization variables that are unset or null. (See the Base Definitions volume of POSIX.1β2017, Section 8.2, Internationalization Variables for the precedence of internationalization variables used to determine the values of locale categories.)LC_ALLβ If set to a non-empty string value, override the values of all the other internationalization variables.LC_CTYPEβ Determine the locale for the interpretation of sequences of bytes of text data as characters (for example, single-byte as opposed to multi-byte characters in arguments).LC_MESSAGESβ Determine the locale that should be used to affect the format and contents of diagnostic messages written to standard error.LC_TIMEβ Determine the format and contents of date and time strings written bydate.NLSPATHβ Determine the location of message catalogs for the processing ofLC_MESSAGES.TZβ Determine the timezone in which the time and date are written, unless the-uoption is specified. If theTZvariable is unset or null and-uis not specified, an unspecified system default timezone is used.
πΈ ASYNCHRONOUS EVENTS πΈ
Default. π«Ά
β STDOUT β
When no formatting operand is specified, the output in the POSIX locale shall be equivalent to specifying:
date "+%a %b %e %H:%M:%S %Z %Y"
π STDERR π
The standard error shall be used only for diagnostic messages.
π OUTPUT FILES π
None. π
π¦ EXTENDED DESCRIPTION π¦
None. (yes bestie, literally nothing here, iconic)
π EXIT STATUS π
The following exit values shall be returned:
0β The date was written successfully. β¨>0β An error occurred. π
π₯ CONSEQUENCES OF ERRORS π₯
Default.
The following sections are informative.
β¨ APPLICATION USAGE β¨
okay bestie, here's the tea on conversion specifiers π
β when you're not in the POSIX locale, their format is literally unspecified. Some of them can even contain <newline> characters in some locales, which lowkey makes it a nightmare to parse date output using the format shown in standard output for those locales. so, y'know, be careful out there π
the range of values for %S goes from 0 to 60 seconds, bestie β yes, sixty β to accommodate the occasional leap second π
and ngl, even though certain conversion specifiers in the POSIX locale (like the name of the month) are shown with initial capital letters, that is NOT necessarily the case in other locales π. Programs using these fields may need to adjust the capitalization if the output is going to be used at the beginning of a sentence. no cap.
The date string formatting capabilities are intended for use in Gregorian-style calendars, possibly with a different starting year (or years). But β plot twist β the %x and %c conversion specifications are intended for local representation, so they may be based on a completely different, non-Gregorian calendar π
The %C conversion specification was introduced to allow a fallback for the %EC (alternative year format base year); it can be viewed as the base of the current subdivision in the Gregorian calendar. The century number is calculated as the year divided by 100 and truncated to an integer β and pls don't confuse it with the use of ordinal numbers for centuries (like, ``twenty-first century''). Both %Ey and %y can then be viewed as the offset from %EC and %C, respectively. iykyk π§
The E and O modifiers modify the traditional conversion specifiers, so that they can always be used β even if the implementation (or the current locale) doesn't support the modifier. iconic behaviour fr fr π
The E modifier supports alternative date formats, such as the Japanese Emperor's Era, as long as these are based on the Gregorian calendar system. Extending the E modifiers to other date elements may provide an implementation-defined extension capable of supporting other calendar systems β especially in combination with the O modifier β¨
The O modifier supports time and date formats using the locale's alternative numerical symbols, such as Kanji or Hindi digits or ordinal number representation. slay.
Non-European locales β whether they use Latin digits in computational items or not β often have local forms of the digits for use in date formats. And this isn't even totally unknown in Europe: a variant of dates uses Roman numerals for the months β the third day of September 1991 would be written as 3.IX.1991 ποΈ. In Japan, Kanji digits are regularly used for dates; in Arabic-speaking countries, Hindi digits are used. The %d, %e, %H, %I, %m, %S, %U, %w, %W, and %y conversion specifications always return the date and time field in Latin digits (that is, 0 to 9). The %O modifier was introduced to support the use for display purposes of non-Latin digits. In the LC_TIME category in localedef, the optional alt_digits keyword is intended for this purpose π
As an example, assume the following (partial) localedef source:
alt_digits "";"I";"II";"III";"IV";"V";"VI";"VII";"VIII" \
"IX";"X";"XI";"XII"
d_fmt "%e.%Om.%Y"
With the above date, the command:
date "+%x"
would yield 3.IX.1991. With the same d_fmt, but without the alt_digits, the command would yield 3.9.1991 π (wild, right?)
πΈ EXAMPLES πΈ
- The following are input/output examples of
dateused at arbitrary times in the POSIX locale:
$ date
Tue Jun 26 09:58:10 PDT 1990
$ date "+DATE: %m/%d/%y%nTIME: %H:%M:%S"
DATE: 11/02/91
TIME: 13:36:16
$ date "+TIME: %r"
TIME: 01:36:32 PM
- Examples for Denmark, where the default date and time format is
%a %d %b %Y %T %Z:
$ LANG=da_DK.iso_8859-1 date
ons 02 okt 1991 15:03:32 CET
$ LANG=da_DK.iso_8859-1 \
date "+DATO: %A den %e. %B %Y%nKLOKKEN: %H:%M:%S"
DATO: onsdag den 2. oktober 1991
KLOKKEN: 15:03:56
- Examples for Germany, where the default date and time format is
%a %d.%h.%Y, %T %Z:
$ LANG=De_DE.88591 date
Mi 02.Okt.1991, 15:01:21 MEZ
$ LANG=De_DE.88591 date "+DATUM: %A, %d. %B %Y%nZEIT: %H:%M:%S"
DATUM: Mittwoch, 02. Oktober 1991
ZEIT: 15:02:02
- Examples for France, where the default date and time format is
%a %d %h %Y %Z %T:
$ LANG=Fr_FR.88591 date
Mer 02 oct 1991 MET 15:03:32
$ LANG=Fr_FR.88591 date "+JOUR: %A %d %B %Y%nHEURE: %H:%M:%S"
JOUR: Mercredi 02 octobre 1991
HEURE: 15:03:56
π RATIONALE π
Some of the new options for formatting are from the ISO C standard. The -u option was introduced to allow portable access to Coordinated Universal Time (UTC) π. The string "GMT0" is allowed as an equivalent TZ value to be compatible with all of the systems using the BSD implementation, where this option originated. no cap, history is wild.
The %e format conversion specification (adopted from System V) was added because the ISO C standard conversion specifications did not provide any way to produce the historical default date output during the first nine days of any month π€ (imagine β single-digit days just vibing with no format)
There are two varieties of day and week numbering supported (in addition to any others created with the locale-dependent %E and %O modifier characters):
- The historical variety in which Sunday is the first day of the week and the weekdays preceding the first Sunday of the year are considered week 0. These are represented by
%wand%U. A variant of this is%W, using Monday as the first day of the week, but still referring to week 0. This view of the calendar was retained because so many historical applications depend on it and the ISO C standardstrftime()function, on which manydateimplementations are based, was defined in this way. - The international standard, based on the ISO 8601:2004 standard where Monday is the first weekday and the algorithm for the first week number is more complex: If the week (Monday to Sunday) containing January 1 has four or more days in the new year, then it is week 1; otherwise, it is week 53 of the previous year, and the next week is week 1. These are represented by the new conversion specifications
%uand%V, added as a result of international comments π
π¦ FUTURE DIRECTIONS π¦
None. (nothing, nada, zero, the future is empty bestie π)
β SEE ALSO β
The Base Definitions volume of POSIX.1β2017, Section 7.3.5, LC_TIME, Chapter 8, Environment Variables, Section 12.2, Utility Syntax Guidelines
The System Interfaces volume of POSIX.1β2017, fprintf(), strftime()
π COPYRIGHT π
Portions of this text are reprinted and reproduced in electronic form from IEEE Std 1003.1-2017, Standard for Information Technology -- Portable Operating System Interface (POSIX), The Open Group Base Specifications Issue 7, 2018 Edition, Copyright (C) 2018 by the Institute of Electrical and Electronics Engineers, Inc and The Open Group. In the event of any discrepancy between this version and the original IEEE and The Open Group Standard, the original IEEE and The Open Group Standard is the referee document. The original Standard can be obtained online at http://www.opengroup.org/unix/online.html .
Any typographical or formatting errors that appear in this page are most likely to have been introduced during the conversion of the source files to man page format. To report such errors, see https://www.kernel.org/doc/man-pages/reporting_bugs.html .
and that's the whole page, bestie π«Ά this one's from IEEE/The Open Group, dated 2017 β DATE(1P), periodt π
β¨ go format some timestamps, you've got this π
π¦ where this page comes from
- alpine 3.22: man-pages-posix 2017a-r0 Β· custom
- alpine 3.23: man-pages-posix 2017a-r0 Β· custom
- alpine 3.24: man-pages-posix 2017a-r0 Β· custom
- arch rolling: man-pages 6.19-1
- arch rolling: man-pages 6.20-1 Β· BSD-2-Clause AND BSD-3-Clause AND BSD-4.3TAHOE AND BSD-4-Clause-UC AND GPL-1.0-or-later AND GPL-2.0-only AND GPL-2.0-or-later AND GPL-3.0-or-later AND LGPL-3.0-linking-exception AND LGPL-3.0-or-later AND LicenseRef-Public-Domain AND LicenseRef-UltraPermissive AND Linux-man-pages-1-para AND Linux-man-pages-copyleft AND Linux-man-pages-copyleft-2-para AND Linux-man-pages-copyleft-var AND MIT AND Spencer-94
- nixpkgs unstable: man-pages-posix 2017a
- opensuse-leap 16.0: man-pages-posix 2017a-160000.4.1 Β· SUSE-IEEE
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms