DATE(1)

NAME
date - print or set the system date and time

SYNOPSIS
date [-u] [-d datestr] [-f datefile] [-R] [-r file] [-s datestr] [--utc] [--universal] [--date=datestr] [--file=datefile] [--rfc-822] [--reference=file] [--set=datestr] [--help] [--version] [+FORMAT] [MMDDhhmm[[CC]YY][.ss]]

DESCRIPTION
This documentation is no longer being maintained and may be inaccurate or incomplete. The Texinfo documentation is now the authoritative source.

This manual page documents the GNU version of date. date with no arguments prints the current time and date (as if the format string was `%a %b %e %H:%M:%S %Z %Y'; the `%' directives are described below). If given an argument that starts with a `+', it prints time and date in a format controlled by that argument, which has the same format as the format string passed to the `strftime' function. Except for directives that start with `%', characters in that string are printed unchanged.

The directives are:

%   a literal %

n   a newline

t   a horizontal tab

Time fields:

%H  hour (00..23)

%I  hour (01..12)

%k  hour ( 0..23)

%l  hour ( 1..12)

%M  minute (00..59)

%p  locale's AM or PM

%r  time, 12-hour (hh:mm:ss [AP]M)

%s  seconds since 1970-01-01 00:00:00 UTC (a nonstandard extension)

%S  second (00..61)

%T  time, 24-hour (hh:mm:ss)

%X  locale's time representation (%H:%M:%S)

%z  RFC-822 style numeric time zone (e.g., -0600 or +0100), or nothing if no time zone is determinable. Note that this value reflects the current timezone; it isn't changed by the `--date' option.

%Z  time zone (e.g., EDT), or nothing if no time zone is determinable. Note that this value reflects the current timezone; it isn't changed by the `--date' option.

Date fields:

%a  locale's abbreviated weekday name (Sun..Sat)

%A  locale's full weekday name, variable length (Sunday..Saturday)

%b  locale's abbreviated month name (Jan..Dec)

%B  locale's full month name, variable length (January..December)

%c  locale's date and time (Sat Nov 04 12:02:33 EST 1989)

%d  day of month (01..31)

%D  date (mm/dd/yy)

%h  same as %b

%j  day of year (001..366)

%m  month (01..12)

%U  week number of year with Sunday as first day of week (00..53). Days in a new year preceding the first Sunday are in week zero.

%V  week number of year with Monday as first day of week (01..53). If the week containing January 1 has four or more days in the new year, then it is considered week 1; otherwise, it is week 53 of the previous year, and the next week is week 1. (See the ISO 8601: 1988 standard.)

%w  day of week (0..6) with 0 corresponding to Sunday

%W  week number of year with Monday as first day of week (00..53) Days in a new year preceding the first Monday are in week zero.

%x  locale's date representation (mm/dd/yy)

%y  last two digits of year (00..99)

%Y  year (1970...)

By default, date pads numeric fields with zeroes. GNU date recognizes the following nonstandard numeric modifiers between the `%' and the directive:

-   (hyphen) do not pad the field

_   (underscore) pad the field with spaces

If given an argument that does not start with `+', date sets the system clock to the time and date specified by that argument. The `--date' and `--set' options may not be used with such an argument. (Note that the `--set' option provides a different way of setting the system clock.) The argument must consist entirely of digits, which have the following meaning:

MM  month

DD  day within month

hh  hour

mm  minute

CC  first two digits of year (optional)

YY  last two digits of year (optional)

ss  second (optional)

Only the superuser can set the system clock.

  OPTIONS

-d datestr, --date=datestr
    Display the time and date specified in datestr, which can be in almost any common format. The display is in the default output format, or if an argument starting with `+' is given to date, in the format specified by that argument.

-f datefile, --file=datefile
    Parse each line in datefile as with `-d' and display the resulting time and date. If datefile is `-', use standard input. This is useful when you have many dates to process, because the system overhead of starting up the `date' executable many times can be considerable.

--help
    Print a usage message on standard output and exit successfully.

-r file, --reference=file
    Display the time and date reference according to the last modification time of file, instead of the current time and date.

-R, --rfc-822
    Display the time and date using the RFC-822-specified format, `%a, %_d %b %Y %H:%M:%S %z'. If `--utc' is also specified, use `GMT' in place of `%z'. -s datestr, --set datestr Set the time and date to datestr, which can be in almost any common format. It can contain month names, timezones, `am' and `pm', etc.

-u, --universal
    Print or set the time and date in Coordinated Universal Time (also known as Greenwich Mean Time) instead of in local (wall clock) time.

--version
    Print version information on standard output then exit successfully.

EXAMPLES

To print the date of the day before yesterday

    date --date '2 days ago'

To print the date of the day three months and one day hence

    date --date '3 months 1 day'

To print the day of year of Christmas in the current year

    date --date '25 Dec' +%j

To print the current date in a format including the full month name and the day of the month

    date '+%B %d'

But this may not be what you want because for the first nine days of the month, the `%d' expands to a zero-padded two-digit field, for example `date -d 1-may '+%B %d'' will print `May 01'.

To print the same date but without the leading zero for one-digit days of month, you can use the nonstandard `-' modifier to suppress the padding altogether.

    date -d 1-may '+%B %-d'