-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdate.txt
More file actions
21 lines (18 loc) · 775 Bytes
/
date.txt
File metadata and controls
21 lines (18 loc) · 775 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# Formatting dates. The format string begins with \e[38;5;201;1m+\e[0m
date +%Y-%m-%d \e[36m# 2025-03-05\e[0m
# or shorter:
date +%F \e[36m# 2025-03-05\e[0m
date +%b --> "Apr"
# Times
+%s \e[36m# seconds since epoch ("unix timestamp")\e[0m
+%H:%M:%S \e[36m# 14:42:58\e[0m
# or shorter:
+%T \e[36m# 14:44:22\e[0m
# Input date:
--date/-d string
# where string can be all sorts of wacky shit, and also accepts +/-n day/month modifiers
# if the input is a timestamp, prefix a \e[38;5;208m@\e[0m
$ date -d \e[38;5;201;1m@\e[0m1749655073
Wed Jun 11 05:17:53 PM CEST 2025
# last date of the month: get the current 1st day of the month, add a month, subtract a day, print as date:
date -d $(date +%Y-%m-01)' +1 month -1 day' +%F \e[36m# 2025-03-31\e[0m