The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
Google UNIX.COM



View Single Post in UNIX Forums - Click on the Thread or Permalink to View Entire Thread -->
  #5 (permalink)  
Old 07-03-2008
nayanasavio nayanasavio is offline
Registered User
 

Join Date: Jul 2008
Posts: 1
Re: Date Calculations

hi there,
date -d '1 week ago'
or
date -d '7 days ago'
will give the date and time of exactly a week ago.
You can use '1 month ago' 'yesterday', '2 hours ago', etc..
For future dates, use 'tomorrow', '2 hours now', '1 week now', etc

Any date before/after any time period can be displayed this way.

Month=$(date -d '1 week ago' +%m)
Day=$(date -d '1 week ago' +%d)
Year=$(date -d '1 week ago' +%y)

echo $Month "/" $Day "/" $Year
Reply With Quote