unix

How do I print a future date on my Linux server?

To print a future date, you can use the date command like the example below.

To get the date 18 months from now in MM/DD/YYYY format:

date +%m”/”%d”/”%Y –date=”18 months”

To get the date 3 weeks from now in MM/DD/YY format:

date +%m”/”%d”/”%y –date=”3 weeks”

If you do not use any special format arguments, you will see the default output like this:

Sat Sep 8 07:31:13 EDT 2012

To change the date to look for previous dates, you can just add the word “ago” to the date.

To get the date from 18 months ago, instead of just:

date +%m”/”%d”/”%Y –date=”18 months”

it is instead

date +%m”/”%d”/”%Y –date=”18 months ago”

Click to comment

Leave a Reply

Your email address will not be published. Required fields are marked *

To Top