Display or change the date

date [OPTION]… [+FORMAT]
date [OPTION] [MMDDhhmm[[CC]YY][.ss]]

&qt;date&qt;&qt; with no arguments prints the current time and date, in the
format of the &qt;&qt;c&qt;&qt; directive (described below).

If given an argument that starts with a &qt;+&qt;&qt;, &qt;date&qt;&qt; prints the
current time and date (or the time and date specified by the &qt;–date&qt;&qt;
option, see below) in the format defined by that argument, which is the
same as in the &qt;strftime&qt;&qt; function. Except for directives, which start
with &qt;&qt;&qt;&qt;, characters in the format string are printed unchanged. The
directives are described below.

-d, –date=STRING display time described by STRING, not &qt;now&qt;&qt;
DATESTR can be in almost any common format.
It can contain month names, timezones, &qt;am&qt;&qt; and &qt;pm&qt;&qt;,
&qt;yesterday&qt;&qt;, &qt;ago&qt;&qt;, &qt;next&qt;&qt;, etc.

-f, –file=DATEFILE like –date once for each line of DATEFILE
If DATEFILE is &qt;-&qt;&qt;, use standard input. This is
useful when you have many dates to process,
because the system overhead of starting up the
&qt;date&qt;&qt; executable many times can be considerable.

-I, –iso-8601[=TIMESPEC] output an ISO-8601 compliant date/time string., &qt;&qt;Y-&qt;m-&qt;d&qt;&qt;.
TIMESPEC=&qt;date&qt;&qt; (or missing) for date only,
&qt;hours&qt;&qt;, &qt;minutes&qt;&qt;, or &qt;seconds&qt;&qt; for date and
time to the indicated precision.
If showing any time terms, then include the time zone
using the format &qt;&qt;z&qt;&qt;. If &qt;–utc&qt;&qt; is also specified,
use &qt;&qt;Z&qt;&qt; in place of &qt;&qt;z&qt;&qt;.

-r, –reference=FILE display the last modification time of FILE

-R, –rfc-822 output RFC-822 compliant date string

-s, –set=STRING set time described by STRING (see -d above)

-u, –utc, –universal print or set Coordinated Universal Time

–help display this help and exit
–version output version information and exit

FORMAT controls the output. The only valid option for the second form
specifies Coordinated Universal Time. Interpreted sequences are:

&qt;&qt; a literal &qt;
&qt;a locale&qt;&qt;s abbreviated weekday name (Sun..Sat)
&qt;A locale&qt;&qt;s full weekday name, variable length (Sunday..Saturday)
&qt;b locale&qt;&qt;s abbreviated month name (Jan..Dec)
&qt;B locale&qt;&qt;s full month name, variable length (January..December)
&qt;c locale&qt;&qt;s date and time (Sat Nov 04 12:02:33 EST 1989)
&qt;d day of month (01..31)
&qt;D date (mm/dd/yy)
&qt;e day of month, blank padded ( 1..31)
&qt;h same as &qt;b, locale&qt;&qt;s abbreviated month name (Jan..Dec)
&qt;H hour :24 hour(00..23)
&qt;I hour :12 hour(01..12)
&qt;j day of year (001..366)
&qt;k hour :24 hour(00..23)
&qt;l hour :12 hour(01..12)
&qt;m month (01..12)
&qt;M minute (00..59)
&qt;n a newline
&qt;p locale&qt;&qt;s AM or PM
&qt;r time, 12-hour (hh:mm:ss [AP]M)
&qt;s seconds since 00:00:00, Jan 1, 1970 (a GNU extension)
Note that this value is defined by the localtime system
call. It isn&qt;&qt;t changed by the &qt;–date&qt;&qt; option.
&qt;S second (00..60)
&qt;t a horizontal tab
&qt;T time, 24-hour (hh:mm:ss)
&qt;U week number of year with Sunday as first day of week (00..53)
&qt;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.)

&qt;w day of week (0..6); 0 represents Sunday
&qt;W week number of year with Monday as first day of week (00..53)
&qt;x locale&qt;&qt;s date representation (mm/dd/yy)
&qt;X locale&qt;&qt;s time representation (&qt;H:&qt;M:&qt;S)
&qt;y last two digits of year (00..99)
&qt;Y year (1970…)
&qt;z RFC-822 style numeric timezone (-0500) (a nonstandard extension)
This value reflects the _current_ time zone.
It isn&qt;&qt;t changed by the &qt;–date&qt;&qt; option.
&qt;Z time zone (e.g., EDT), or nothing if no time zone is determinable
This value reflects the _current_ time zone.
It isn&qt;&qt;t changed by the &qt;–date&qt;&qt; option.

By default, date pads numeric fields with zeroes. GNU date recognizes
the following modifiers between &qt;&qt;&qt;&qt; and a numeric directive.

&qt;-&qt;&qt; (hyphen) do not pad the field; useful if the output is intended for
human consumption.

&qt;_&qt;&qt; (underscore) pad the field with spaces; useful if you need a fixed
number of characters in the output, but zeroes are too distracting.

The – and _ are GNU extensions.

Here is an example illustrating the differences:

date +&qt;d/&qt;m -d "Feb 1"
=> 01/02
date +&qt;-d/&qt;-m -d "Feb 1"
=> 1/2
date +&qt;_d/&qt;_m -d "Feb 1"
=> 1/ 2

Setting the time
If given an argument that does not start with &qt;+&qt;&qt;, &qt;date&qt;&qt; sets the
system clock to the time and date specified by that argument (as
described below). You must have appropriate privileges to set the
system clock. The &qt;–date&qt;&qt; and &qt;–set&qt;&qt; options may not be used with
such an argument. The &qt;–universal&qt;&qt; option may be used with such an
argument to indicate that the specified time and date are relative to
Coordinated Universal Time rather than to the local time zone.

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)

The &qt;–set&qt;&qt; option also sets the system clock; see the next section.

Examples of &qt;date&qt;&qt;

* To print the date of the day before yesterday:
date –date=&qt;&qt;2 days ago&qt;&qt;

* To print the date of the day three months and one day hence:
date –date=&qt;&qt;3 months 1 day&qt;&qt;

* To print the day of year of Christmas in the current year:
date –date=&qt;&qt;25 Dec&qt;&qt; +&qt;j

* To print the current full month name and the day of the month:
date &qt;&qt;+&qt;B &qt;d&qt;&qt;

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

* Print a date without the leading zero for one-digit days of the
month, you can use the (GNU extension) &qt;-&qt;&qt; modifier to suppress
the pa
dding altogether.
date -d=1may &qt;&qt;+&qt;B &qt;-d&qt;&qt;

* Print the current date and time in the format required by many
non-GNU versions of &qt;date&qt;&qt; when setting the system clock:
date +&qt;m&qt;d&qt;H&qt;M&qt;Y.&qt;S

* Set the system date and time
date –set=“2002-6-29 11:59 AM”

* Set the system clock forward by two minutes:
date –set=&qt;&qt;+2 minutes&qt;&qt;

* Print the date in the format specified by RFC-822, use &qt;date
–rfc&qt;&qt;. I just did and saw this:

Mon, 25 Mar 1996 23:34:17 -0600

* To convert a date string to the number of seconds since the epoch
(which is 1970-01-01 00:00:00 UTC), use the &qt;–date&qt;&qt; option with
the &qt;&qt;s&qt;&qt; format. That can be useful in sorting and/or graphing
and/or comparing data by date. The following command outputs the
number of the seconds since the epoch for the time one second later
than the epoch, but in time zone five hours later (Cambridge,
Massachusetts), thus a total of five hours and one second after
the epoch:

date –date=&qt;&qt;1970-01-01 00:00:01 UTC +5 hours&qt;&qt; +&qt;s

Suppose you had _not_ specified time zone information in the
example above. Then, date would have used your computer&qt;&qt;s idea of
the time zone when interpreting the string. Here&qt;&qt;s what you would
get if you were in Greenwich, England:

# local time zone used
date –date=&qt;&qt;1970-01-01 00:00:01&qt;&qt; +&qt;s

* If you&qt;&qt;re sorting or graphing dated data, your raw date values may
be represented as seconds since the epoch. But few people can
look at the date &qt;946684800&qt;&qt; and casually note "Oh, that&qt;&qt;s the
first second of the year 2000."

date –date=&qt;&qt;2000-01-01 UTC&qt;&qt; +&qt;s

To convert such an unwieldy number of seconds back to a more
readable form, use a command like this:

date -d &qt;&qt;1970-01-01 946684800 sec&qt;&qt; +"&qt;Y-&qt;m-&qt;d &qt;T &qt;z"
2000-01-01 00:00:00 +0000