Skip to content

Latest commit

 

History

History
45 lines (38 loc) · 1.04 KB

linux-date-command-cheatsheet.md

File metadata and controls

45 lines (38 loc) · 1.04 KB
aliases category classification date date_modified draft id image links local_archive_links pinned print series tags title type
linux-date-command-cheatsheet
cli
public
2020-10-13 12:02:22 -0700
2020-10-13 12:02:22 -0700
false
20201013190222
false
false
date
linux
shell
Linux Date Command
tech-note

Commands

date --set="23:59:58"                       # Set the system time.
date --set="2020-10-17"                     # Set the system date.
date --date=@1593966863                     # Convert from specifed Epoch time.
date --date=@1593964977 +"%Y%m%d%H%M%S"     # Convert from specified Epoch time to specific format.
date +%s -d "Jan 1, 1980 00:00:01"          # Convert from human readable to Epoch.

Functions

Print out Concurrent Date's

I use this for my plain-text calendar. Update the START and END date variables, and then you have a list of dates you can use.

#!/bin/bash
START="2021-01-01"
for i in {1..365}; do
    # custom format using +
    date '+%Y-%m-%d %a' -d "$START +$i days"
done