Linux Command - date

date - display or set system time.

Syntax

1
date [OPTIONS] [+FORMAT]

Format

common FORMAT Description
%Y year
%y last two digits of year(00…99)
%m month
%d day of month(e.g. 01)
%F full date; same as %Y-%m-%d
%H hour(00…23)
%l hour(01…12)
%k hour(0…23)
%M minute (00..59)
%S second (00..60)
%T time; same as %H:%M:%S

Options

Option Description
-d, --date=STRING display time described by STRING, not ‘now’
-u print or set Coordinated Universal Time

Examples

Display date in UTC and ISO 8601 format

1
date -u +"%Y-%m-%dT%H:%M:%SZ"

Display date using default locale’s format

1
date +%c

sample output

1
Mon 07 Jan 2019 09:21:51 PM EST

Display date and time

1
date +"%F %T"

output

1
2019-01-07 21:14:37

Display unix time

Unix time is seconds since Unix epoch

1
date +%s

Display a future date

next month

1
date -d next-month +%Y-%m

Nov 25 of the year

1
date -d 'nov 25' +%F

10 minutes later

1
date -d '10 minutes' +%H:%M:%S

Reference