Linux date command

Nov 28, 2017

The date command is mostly used to get the current date. But there are some underappreciated gems of feature in this command.

Get a date in the past

> date -d "3 days ago"
> date -d "last month"

Or in the future

> date -d "-3 days ago"
> date -d "next month"

You can also get creative like these examples below

> date -d "3 days ago last year"
> date -d "3 days ago next year" 
> date -d "next year next month"