Date calculate in script

user-pic
Vote 0 Votes

100 days after 2010-11-30
# date +%Y-%m-%d -d "2010-11-30 100 day"
2011-03-10

100 days before 2010-11-30
# date +%Y-%m-%d -d "2010-11-30 -100 day"
2010-08-22

How many days between 2010-06-01 and 2010-11-30 (in same year)
# echo $[`date +%j -d 2010-11-30`-`date +%j -d 2010-06-01`]
182

How many days between 2010-11-30 and 2012-12-22 (in different year)
# echo $[(`date +%s -d 2012-12-22`-`date +%s -d 2010-11-30`)/86400]
753

Leave a comment

About this Entry

This page contains a single entry by Pank published on November 30, 2010 1:15 AM.

XBOX 360 S 4G + EZLINK BLACK HAWK 16G was the previous entry in this blog.

NIS setup script for CentOS is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Monthly Archives