date - Write the date and time

Synopsis

date [-u] [+format]

Description

The date utility writes the date and time to standard output. By default, the current date and time are written.

Options

-u
Give time in universal coordinated time (UTC). The QUTCOFFSET system value must be set correctly for date to return the correct time.

Operands

The +format operand specifies the format of the output from the date command. Each field descriptor is replaced in the standard output by its corresponding value. All other characters are copied to the output without change. The output is always terminated with a newline character.

You can use these field descriptors:

%a
Insert abbreviated weekday name from locale.
%A
Insert full weekday name from locale.
%b
Insert abbreviated month name from locale.
%B
Insert full month name from locale.
%c
Insert date and time from locale.
%d
Insert day of the month (01-31).
%H
Insert hour (24-hour clock) as a decimal number (00-23).
%I
Insert hour (12-hour clock) as a decimal number (01-12).
%j
Insert day of the year (001-366).
%m
Insert month (01-12).
%M
Insert minute (00-59).
%p
Insert equivalent of either AM or PM from locale.
%S
Insert second (00-61).
%U
Insert week number of the year (00-53) where Sunday is the first day of the week.
%w
Insert weekday (0-6) where Sunday is 0. first day of the week.
%W
Insert week number of the year (00-53) where Monday is the first day of the week
%x
Insert date representation from locale.
%X
Insert time representation from locale.
%y
Insert year without the century (00-99).
%Y
Insert year.
%Z
Insert name of time zone, or no characters if time zone is not available.
%%
Insert %.

Exit status

  • 0 when successful
  • >0 when an error occurred

Examples

  1. Print the full weekday name, the full month name, the day and the full year.
    date +@(#) 89 1.41@(#), 0 %d%, %Y
    Friday, August 14, 1998
  2. Print the day, the abbreviated month name, and the abbreviated year.
    date +%d%.%b%.%y
    14.Aug.98
  3. Print the numeric month, day, and abbreviated year.
    date +%m%/%d%/%y
    08/14/98