Signup/Sign In
Ask Question
Not satisfied by the Answer? Still looking for a better solution?

How do I add X days to date and get new date?

I need to add/calculate 10 days plus date so then I will get new date (expiration date))

for example
# date 
Sun Sep 11 07:59:16 IST 2012


So I need to get
NEW_expration_DATE = Sun Sep 21 07:59:16 IST 2012


Please advice how to calculate the new expiration date ( with bash , ksh , or manipulate date command ?)
by

1 Answer

Kajalsi45d
You can just use the -d switch and provide a date to be calculated
date
Sun Sep 23 08:19:56 BST 2012
NEW_expration_DATE=$(date -d "+10 days")
echo $NEW_expration_DATE
Wed Oct 3 08:12:33 BST 2012


This is quite a powerful tool as you can do things like
date -d "Sun Sep 11 07:59:16 IST 2012+10 days"
Fri Sep 21 03:29:16 BST 2012

Login / Signup to Answer the Question.