Skip to content

CMD date

zplutor edited this page Sep 27, 2023 · 2 revisions

Date Command

Converts between human readable date time string and UNIX timestamp.

Usage

date [<timestamp>] [<adjustment>] [/e]

timestamp is a UNIX timestamp like 1664430057. If it is omitted, current timestamp will be used.

adjustment is used to adjust the time by a specified amount of unit. An adjustment starts with a + or -, and then an integer followed by an unit identifier, such as +10s, -7d. Available unit identifiers are:

  • s, seconds
  • min, minutes
  • h, hours
  • d, days
  • w, weeks
  • mon, months
  • y, years

If unit identifier is omitted, seconds will be used. There can be multiple adjustments as arguments.

/e switch indicates that the result is displayed as a UNIX timestamp rather than a human readable string.

Example

Dispaly current date time:
date

Display the date time 180 days ago:
date -180d

Convert current date time to a UNIX timestamp:
date /e

Convert an UNIX timestamp to human readable string:
date 1664430057

Clone this wiki locally