mirror of
https://github.com/jbranchaud/til
synced 2026-01-02 22:58:01 +00:00
Add Print The Current Date In Human-Readable Format as a Unix TIL
This commit is contained in:
@@ -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).
|
||||
|
||||
_1307 TILs and counting..._
|
||||
_1308 TILs and counting..._
|
||||
|
||||
---
|
||||
|
||||
@@ -1298,6 +1298,7 @@ _1307 TILs and counting..._
|
||||
- [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 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)
|
||||
- [Provide A Fallback Value For Unset Parameter](unix/provide-a-fallback-value-for-unset-parameter.md)
|
||||
- [Remove A Directory Called `-p`](unix/remove-a-directory-called-dash-p.md)
|
||||
- [Repeat Yourself](unix/repeat-yourself.md)
|
||||
|
||||
26
unix/print-the-current-date-in-human-readable-format.md
Normal file
26
unix/print-the-current-date-in-human-readable-format.md
Normal file
@@ -0,0 +1,26 @@
|
||||
# Print The Current Date In Human-Readable Format
|
||||
|
||||
The `date` utility by default does a good job of displaying the current date in
|
||||
a human-readable format.
|
||||
|
||||
```bash
|
||||
❯ date
|
||||
Fri Jun 2 11:30:03 CDT 2023
|
||||
```
|
||||
|
||||
It has some additional info like the time and timezone.
|
||||
|
||||
If I just want to see the date with the day of the week, I can call `date` with
|
||||
a format string that uses special identifiers for each part of the date. This
|
||||
gives me control over exactly how it is displayed. For example, the following
|
||||
format string works for my purposes.
|
||||
|
||||
```bash
|
||||
❯ date '+%A %B %d, %Y'
|
||||
Friday June 02, 2023
|
||||
```
|
||||
|
||||
The `+` indicates that it is a user-specified format string and the rest of the
|
||||
special identifiers are defined by `strftime`.
|
||||
|
||||
See `man date` and `man strftime` for more details.
|
||||
Reference in New Issue
Block a user