Work

Find A Future Date From The Shell

Have you ever needed the exact date a certain number of days in the future? The Command-Line Fu site shows how to use the date command to calculate future (and past) dates.

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 3 weeks in the future, use the following command from the shell prompt:

date -d “3 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 “3 weeks ago”

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

date -d “3 weeks 2 days”

It’s a very simple tip, but for those of us that have a terminal window open at all times, it can really come in handy. For more geeky terminal tips, check out how to display a list of just the subdirectories, turn any Linux directory into an ISO file, or take a look through our top 10 command-line tools.

Date shows dates at other times/dates [Command-Line Fu]

Comments (AU Comments | US Comments)

  • Jo

    Really this is only setting the kernel’s offset for daylight savings.

Post Your Comments

Got something to say? There are two ways to comment:

1. Guests

Click here to comment instantly.

2. Facebook Users

Click below to comment using your Facebook account.

We're looking for comments that are interesting, substantial or highly amusing. If your comments are excessively self-promotional, obnoxious, or even worse, boring, you will be banned from commenting. All comments are moderated.