linux date cheatsheet

Yugal Arora
Aug 6, 2022

--

Some quick handy formats that can be used with date command on linux.

Example:

date +'%d'
06
date +'%m'
08
date +'%Y'
2022
date +'%m-%d-%Y'
08-06-2022
date +'%m/%d/%Y %H:%M:%S'
08/06/2022 21:12:40
date +'%m/%d/%Y %H:%M:%S %p'
08/06/2022 21:12:28 PM
date +'%x %T %p'
08/06/22 21:11:59 PM
bonus (to print current epoch time):
date +'%s'
1659820538

Reference: Chapter10: Time, The Linux Programming Interface Michael Kerrisk

--

--

Yugal Arora
Yugal Arora

Written by Yugal Arora

Site Reliability Developer @ Oracle Cloud Infrastructure

No responses yet