Linux provides commands that allow you to view system’s date information, and with these commands, you can quickly get the date related information.

System Date

We can use the date command to get or set the date of the system:

1
date
img

Prints datetime

Locale Datetime

1
date +'%c'
img

Prints locale's datetime

Locale Date

1
date +'%x'
img

Prints locale's time

Locale Weekday - Abbreviation

1
date +'%a'
img

Prints locale's abbreviated weekday name

Locale Weekday - Full Name

1
date +'%A'
img

Prints locale's full weekday name

Locale Month - Abbreviation

1
date +'%b'    # This is equivalent to date +'%h'
img

Prints locale's abbreviated month name

Locale Month - Full Name

1
date +'%B'
img

Prints locale's full month name

Date - YYYY-MM-DD (ISO 8601 format)

1
date +'%F'
img

Prints date in YYYY-MM-DD format

Date - DD/MM/YY

1
date +'%D'
img

Prints date in DD/MM/YY format

Century

1
date +'%C'
img

Prints century

Year - YYYY

1
date +'%Y'
img

Prints year in YYYY format

Year - YY

1
date +'%y'
img

Prints year in YY format

Month - MM

1
date +'%m'
img

Prints month in MM format

Week of Year - 00 to 53 (First Day Monday)

1
date +'%W'
img

Prints Monday first week number

Week of Year - 00 to 53 (First Day Sunday)

1
date +'%U'
img

Prints Sunday first week number

ISO Week Number Year - YY

1
date +'%g'
img

Prints week number year in YY format

ISO Week Number Year - YYYY

1
date +'%G'
img

Prints week number year in YYYY format

Day of Week - Zero to Six

1
date +'%w'    # 0 corresponding to Sunday
img

Prints day of week zero to six

Day of Week - One to Seven

1
date +'%u'    # 1 corresponding to Monday
img

Prints day of week one to seven

Day of Month

1
date +'%d'
img

Prints day of month

Day of Month - Space Padded

1
date +'%e'
img

Prints space padded day of month

Day of Year

1
date +'%j'
img

Prints day of year

Day or Days Ago

1
date --date='1 day ago'
img

Prints a day ago

1
date --date='2 days ago'
img

Prints two days ago

Day or Days Hence

1
date --date='1 day'
img

Prints a day hence

1
date --date='2 days'
img

Prints two days hence

Month or Months Ago

1
date --date='1 month ago'
img

Prints a month ago

1
date --date='2 months ago'
img

Prints two months ago

Month or Months Hence

1
date --date='1 month'
img

Prints a month hence

1
date --date='2 months'
img

Prints two months hence

Year or Years Ago

1
date --date='1 year ago'
img

Prints a year ago

1
date --date='2 years ago'
img

Prints two years ago

Year or Years Hence

1
date --date='1 year'
img

Prints a year hence

1
date --date='2 years'
img

Prints two years hence

References 21 System context, 21.1.2 Date conversion specifiers, 21.1.7 Examples of date

Buy me a coffeeBuy me a coffee