Linux Date Command

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

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

About

I'm a technology professional who's been passionate about computers since my Grandad introduced me to an Intel 386 back in the 90s when I was a kid. Those moments inspired a passion within for technology, and I've been playing around with anything with a circuit board ever since. Whenever I have a moment you can probably find me working on something computer-related, and this is where I like to write about those moments.