Find a Future Date from the Shell

Posted on 29. Apr, 2009 by Nikhil Sheth in Knowledge, Tips

Have you ever needed the exact date a certain number of days in the future?
Using the date command is simple—just open a terminal window on your Mac, Linux, or Windows with Cygwin desktop, use the date command with the -d parameter, and pass in a number of date increments in the future in days, minutes, years, months, or even weeks. For instance, to find the date 4 weeks in the future, use the following command from the shell prompt:

date -d "4 weeks"

To find the date from a period of time in the past, you would add “ago” to the end of the command:

date -d "4 weeks ago"

You can even combine the arguments together—so if you wanted to find the exact date for 4 weeks and 1 days in the future, you would use:

date -d "4 weeks 1 days"

Share and Enjoy:
  • Twitter
  • Digg
  • StumbleUpon
  • Facebook
  • del.icio.us
  • Yahoo! Buzz
  • Google Bookmarks
  • FriendFeed
  • LinkedIn
  • Technorati
  • Yahoo! Bookmarks
  • DZone

Related posts:

  1. To HUP or nohup?
  2. Creating Bash Aliases

Tags:

Leave a reply

Anti-Spam Protection by WP-SpamFree

Get Adobe Flash playerPlugin by wpburn.com wordpress themes