Date -d format to display date/time described by STRING on Linux


I saw some info on displaying custom date using date -d sting. How do I use it on Linux operating system?

The default is now which shows the current date and time

date -d 'now'

Above is same as typing


The date -d ‘string’ show the date and time specified in datestr instead of the current date and time. datestr can be in almost any common format. It can contain month names, time zones, ‘am’ and ‘pm’, ‘yesterday’.

Examples of date -d ‘string’ format

Print the date of the day before yesterday:

date -d '1 day ago'
date --date='2 days ago'

Try some more:

date -d '1 month ago'
date -d '1 year ago'
date -d 'yesterday'
date -d 'tomorrow'

For more info see my tutorials:

  1. Getting Yesterdays or Tomorrows Day With Bash Shell Date Command
  2. HowTo Format Date For Display or Use In a Shell Script