Simple CLI date calculator

I needed to know the date of something that occurred 30 days prior to the UNIX timestamp value. Here’s how I did it.

First, I converted the UNIX timestamp using the GNU date command found in coreutils:

$ gdate -d @1459966497
Wed Apr  6 11:14:57 PDT 2016

From there, gdate is pretty flexible on input formats:

$ gdate -d 'Apr 6 - 30 days'
Mon Mar  7 00:00:00 PST 2016

(nb: I used Homebrew to install GNU coreutils, and it prefixed all the utilities with “g” to differentiate them from their BSD equivalients. On GNU/Linux systems, regular date should probably be used.)