Bash datetime

From wikinotes
Revision as of 23:24, 11 May 2018 by Will (talk | contribs) (→‎date formatting)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

WARNING:

Date is not a feature of bash, but part of the gnu or bsd coreutils. That means that it is not as portable as you might like.

date parsing

gnu-coreutils

date -d "2 days ago"
date -d "thursday"
date -d "last thursday"

bsd-coreutils

date formatting

gnu-coreutils

date '+%d/%m/%Y %H:%M:%S'  #> 01/09/2018 10:00:00

bsd-coreutils