# Date

*doing fun stuff with the linux date command*

## Show the week number

```bash
date +%U
```

## ISO8601 format

```bash
date --iso
```

or using [homebrew](https://brew.sh):

```bash
gdate --iso
```

MacOS date command doesn't support `iso`, here are some useful variations:

```bash
date "+%Y-%m-%d"
```
```bash
date "+%Y%m%dT%H%M%S"
```

## Yesterday and Tomorrow

```bash
$ 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:

```bash
$ 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!
0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9