Search This Blog

Wednesday, November 4, 2009

Linux, date tool trick

How many times did you have to get same date and do something with it. To calculate this dates is very annoying, unless you know a few tricks with date command :).

How to find quickly some dates:

$ date -d yesterday
$ date -d '2 days ago'
$ date -d '1 week ago'
$ date -d tomorrow
$ date -d '2 days'
$ date -d '1 week'

For example, when did you born:

$ date
Di 12 Aug 11:44:57 CEST 2008
$ date -d "11 days ago 7 month ago 28 years ago"
Di 1 Jan 10:43:49 CET 1980

No comments:

Post a Comment