Add / substract time in bash

To add or substract any amount of seconds, minutes, hours, days, weeks, months or years to/from current date use the Linux date command:

date -d '+2 hour'

If you want to use specific date as a base:

date -d '2010-01-01 + 2 year'

Leave a Reply

Your email address will not be published.