rdm.sh
Attachments
History
Blame
View Source
Changelog
Documentation
About An Otter Wiki
Toggle dark mode
Login
Home
A - Z
Menu
Mesh
Howto
Date
252423
Commit
252423
2026-04-23 05:27:14
David Marsh
: -/-
howto/date.md
..
@@ 1,5 1,66 @@
# Date
+
*doing fun stuff with the linux date command*
+
## Show the week number
-
date +%U
+
`date +%U`
+
+
## ISO8601 format
+
+
```bash
+
$ date --iso
+
2021-09-27
+
```
+
+
MacOS date command doesn't support `iso`, here are some useful variations:
+
+
```bash
+
$ date "+%Y-%m-%d"
+
2021-09-27
+
+
$ date "+%Y%m%dT%H%M%S"
+
20210927T093333
+
```
+
+
## 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