date -d: what are the accepted strings?

I am using the "date" command to perform some simple date arithmetic. The "-d" option lets me do this, but the man pages are very unclear on what is valid data. What are all the accepted options, and how do I figure that out?

I can use this command to determine the date 5 minutes ago: date -d "5-minutes-ago" +%H:%M

This command also works: date -d "-5 minutes" +%H:%M

I stumbled upon these options by accident/frustration. I don't see a "minutes-ago" or a "-X minutes" option listed in the documentation.

I would use Perl to do the arithmetic, but unfortunately I cannot install any additional Perl packages.


There are a few relative date strings. minutes ago works (vs. minutes-ago with the dash).

There are quite a few examples on the coreutils date info pages:

http://www.gnu.org/software/coreutils/manual/html_node/Date-input-formats.html


A tricky one is the UNIX timestamp format (this is useful if you are managing a textfile database -- you want to keep your date/time data as UNIX timestamps so you can perform interger math on them)

$ date +%s
1299273353
$ date -d @1299273353
Fri Mar  4 15:15:53 CST 2011

The at-sign tells the date command that the number is a UNIX timestamp