Date
doing fun stuff with the linux date command
Show the week number
date +%U
ISO8601 format
date --iso
or using homebrew:
gdate --iso
MacOS date command doesn't support iso, here are some useful variations:
date "+%Y-%m-%d"
date "+%Y%m%dT%H%M%S"
Yesterday and Tomorrow
$ date +%A --date today-1days Wednesday $ date +%A --date today+1days Friday $ date +%A --date yesterday Wednesday $ date +%A --date "2 days ago" Tuesday
This also works as expected for other variables:
$ date +%Y --date "last year" 2011 $ date --date "next monday" Mon Mar 19 00:00:00 EST 2012
Here's the entry from the man page:
DATE STRING The --date=STRING is a mostly free format human readable date string such as "Sun, 29 Feb 2004 16:21:42 -0800" or "2004-02-29 16:21:42" or even "next Thursday". A date string may contain items indicating calendar date, time of day, time zone, day of week, relative time, relative date, and numbers. An empty string indicates the beginning of the day. The date string format is more complex than is easily documented here but is fully described in the info documentation.
damn you info docs!