For Techs.... Techniques.... Technologies....


How to get the past and future dates in bash

There are so many situations where we need to calculate the past and future dates in Linux. We can use the bash command 'date' for calculating this.

To calclulate past dates:

  • date -d "yesterday"
  • date -d "1 day ago"
  • date -d "1 week ago"
  • date -d "1 month ago"
  • date -d "1 year ago"

To calculate future dates:

  • date -d "tomorrow"
  • date -d "1 day"
  • date -d "1 week"
  • date -d "1 month"
  • date -d "1 year"


Leave a Reply