1
0
mirror of https://github.com/jbranchaud/til synced 2026-01-04 15:48:01 +00:00
Files
til/unix/print-the-current-date-in-human-readable-format.md

27 lines
778 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 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.