Name

date [options] [format] — coreutils

Synopsis

/bin stdin stdout - file -- opt --help --version

The date command prints dates and times. By default, it prints the system date and time in the local timezone:

$ date
Sun Sep 28 21:01:31 EDT 2003

You can format the output differently by supplying a format string beginning with a plus sign:

$ date '+%D'
09/28/03
$ date '+The time is %l:%M %p on a beautiful %A in %B'
The time is  9:01 PM on a beautiful Sunday in September

Format

Meaning

Example

Whole dates and times:

 

%c

Full date and time, 12-hour clock

Sun 28 Sep 2003, 09:01:25 PM EDT

%D

Numeric date, 2-digit year

09/28/03

%x

Numeric date, 4-digit year

09/28/2003

%T

Time, 24-hour clock

21:01:25

%X

Time, 12-hour clock

09:01:25 PM

Words:

 

%a

Day of week (abbreviated)

Sun

%A

Day of week (complete)

Sunday

%b

Month name (abbreviated)

Sep

%B

Month name (complete)

September

%Z

Time zone

EDT

%p

AM or PM

PM

Numbers:

 

%w

Day of week (0–6, 0=Sunday)

0

%u

Day of week (1–7, 1=Monday)

7

%d

Day of month, leading zero

02

%e

Day of month, leading blank

2

%j

Day of year, leading zeroes

005

%m

Month number, leading zero

09

%y

Year, 2 digits

03

%Y

Year, 4 digits

2003

%M

Minute, leading zero

09

%S

Seconds, leading zero

05

%l

Hour, 12-hour clock, leading blank

9

%I

Hour, 12-hour clock, leading zero

09

%k

Hour, 24-hour clock, leading blank

9

%H

Hour, 24-hour clock, leading zero

09

%N

Nanoseconds

737418000

%s

Seconds since the beginning of Linux time: midnight January 1, 1970

1068583983

Other:

 

%n

Newline

 

%t

Tab

 

%%

Percent sign

%

Through its options, date can also display other dates and times.

Useful options ...

Get Linux Pocket Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.