Linux

date

SafeShow and compute dates

date '+%Y-%m-%d %H:%M:%S'

Formats dates; -d computes expressions like '3 days ago' — essential for log names and batch windows.

Examples

  • date -d '7 days ago' +%Y%m%dThe date a week ago

Syntax

date ['+format'] [-d 'expr'] [-u]

Before you run it

Read only (set time via timedatectl).

Related commands

The same reference, with no signal at all

Every command and flow from this site, held on your device and searchable with no connection. Free to install, no ads.

Get it free on the App Store