1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-03 15:18:01 +00:00

Add Print DateTime Represented By Unix Timestamp as a Unix TIL

This commit is contained in:
jbranchaud
2024-04-08 09:24:09 -05:00
parent f54eab20e7
commit c2f30615c3
2 changed files with 18 additions and 1 deletions

View File

@@ -10,7 +10,7 @@ pairing with smart people at Hashrocket.
For a steady stream of TILs, [sign up for my newsletter](https://crafty-builder-6996.ck.page/e169c61186).
_1406 TILs and counting..._
_1407 TILs and counting..._
---
@@ -1397,6 +1397,7 @@ _1406 TILs and counting..._
- [Partial String Matching In Bash Scripts](unix/partial-string-matching-in-bash-scripts.md)
- [PID Of The Current Shell](unix/pid-of-the-current-shell.md)
- [Print A Range Of Lines For A File With Bat](unix/print-a-range-of-lines-for-a-file-with-bat.md)
- [Print DateTime Represented By Unix Timestamp](unix/print-datetime-represented-by-unix-timestamp.md)
- [Print Milliseconds In Human-Readable Format](unix/print-milliseconds-in-human-readable-format.md)
- [Print Out Files In Reverse](unix/print-out-files-in-reverse.md)
- [Print The Current Date In Human-Readable Format](unix/print-the-current-date-in-human-readable-format.md)

View File

@@ -0,0 +1,16 @@
# Print DateTime Represented By Unix Timestamp
A lot of tools and systems use a Unix timestamp to represent a point in time.
It is the number of seconds since the Unix epoch (Jan 1, 1970). However, just
looking at a timestamp like `1623867544` doesn't tell a human much. I can't
mentally translate that to the date and time that it is representing.
The `date` utility can help. Give it the `-r` flag with the timestamp value (in
seconds) and it will display the date and time in a human-readable format.
```bash
date -r '1623867544'
Wed Jun 16 13:19:04 CDT 2021
```
See `man date` for more details.