1
Fork 0
mirror of https://github.com/RGBCube/uutils-coreutils synced 2025-09-16 11:46:17 +00:00

Improve the date md page

This commit is contained in:
Sylvestre Ledru 2023-04-26 08:48:02 +02:00
parent 6f0e4ece9d
commit 583a247d9d

View file

@ -2,64 +2,65 @@
<!-- spell-checker:ignore (format) hhmm --> <!-- spell-checker:ignore (format) hhmm -->
``` text
FORMAT controls the output. Interpreted sequences are: FORMAT controls the output. Interpreted sequences are:
%% a literal % | Sequence | Description | Example |
%a locale's abbreviated weekday name (e.g., Sun) | -------- | -------------------------------------------------------------------- | ---------------------- |
%A locale's full weekday name (e.g., Sunday) | %% | a literal % | % |
%b locale's abbreviated month name (e.g., Jan) | %a | locale's abbreviated weekday name | Sun |
%B locale's full month name (e.g., January) | %A | locale's full weekday name | Sunday |
%c locale's date and time (e.g., Thu Mar 3 23:05:25 2005) | %b | locale's abbreviated month name | Jan |
%C century; like %Y, except omit last two digits (e.g., 20) | %B | locale's full month name | January |
%d day of month (e.g., 01) | %c | locale's date and time | Thu Mar 3 23:05:25 2005|
%D date; same as %m/%d/%y | %C | century; like %Y, except omit last two digits | 20 |
%e day of month, space padded; same as %_d | %d | day of month | 01 |
%F full date; same as %Y-%m-%d | %D | date; same as %m/%d/%y | 12/31/99 |
%g last two digits of year of ISO week number (see %G) | %e | day of month, space padded; same as %_d | 3 |
%G year of ISO week number (see %V); normally useful only with %V | %F | full date; same as %Y-%m-%d | 2005-03-03 |
%h same as %b | %g | last two digits of year of ISO week number (see %G) | 05 |
%H hour (00..23) | %G | year of ISO week number (see %V); normally useful only with %V | 2005 |
%I hour (01..12) | %h | same as %b | Jan |
%j day of year (001..366) | %H | hour (00..23) | 23 |
%k hour, space padded ( 0..23); same as %_H | %I | hour (01..12) | 11 |
%l hour, space padded ( 1..12); same as %_I | %j | day of year (001..366) | 062 |
%m month (01..12) | %k | hour, space padded ( 0..23); same as %_H | 3 |
%M minute (00..59) | %l | hour, space padded ( 1..12); same as %_I | 9 |
%n a newline | %m | month (01..12) | 03 |
%N nanoseconds (000000000..999999999) | %M | minute (00..59) | 30 |
%p locale's equivalent of either AM or PM; blank if not known | %n | a newline | \n |
%P like %p, but lower case | %N | nanoseconds (000000000..999999999) | 123456789 |
%q quarter of year (1..4) | %p | locale's equivalent of either AM or PM; blank if not known | PM |
%r locale's 12-hour clock time (e.g., 11:11:04 PM) | %P | like %p, but lower case | pm |
%R 24-hour hour and minute; same as %H:%M | %q | quarter of year (1..4) | 1 |
%s seconds since 1970-01-01 00:00:00 UTC | %r | locale's 12-hour clock time | 11:11:04 PM |
%S second (00..60) | %R | 24-hour hour and minute; same as %H:%M | 23:30 |
%t a tab | %s | seconds since 1970-01-01 00:00:00 UTC | 1615432800 |
%T time; same as %H:%M:%S | %S | second (00..60) | 30 |
%u day of week (1..7); 1 is Monday | %t | a tab | \t |
%U week number of year, with Sunday as first day of week (00..53) | %T | time; same as %H:%M:%S | 23:30:30 |
%V ISO week number, with Monday as first day of week (01..53) | %u | day of week (1..7); 1 is Monday | 4 |
%w day of week (0..6); 0 is Sunday | %U | week number of year, with Sunday as first day of week (00..53) | 10 |
%W week number of year, with Monday as first day of week (00..53) | %V | ISO week number, with Monday as first day of week (01..53) | 12 |
%x locale's date representation (e.g., 12/31/99) | %w | day of week (0..6); 0 is Sunday | 4 |
%X locale's time representation (e.g., 23:13:48) | %W | week number of year, with Monday as first day of week (00..53) | 11 |
%y last two digits of year (00..99) | %x | locale's date representation (e.g., 12/31/99) | 03/03/2005 |
%Y year | %X | locale's time representation (e.g., 23:13:48) | 23:30:30 |
%z +hhmm numeric time zone (e.g., -0400) | %y | last two digits of year (00..99) | 05 |
%:z +hh:mm numeric time zone (e.g., -04:00) | %Y | year | 2005 |
%::z +hh:mm:ss numeric time zone (e.g., -04:00:00) | %z | +hhmm numeric time zone (e.g., -0400) | -0400 |
%:::z numeric time zone with : to necessary precision (e.g., -04, +05:30) | %:z | +hh:mm numeric time zone (e.g., -04:00) | -04:00 |
%Z alphabetic time zone abbreviation (e.g., EDT) | %::z | +hh:mm:ss numeric time zone (e.g., -04:00:00) | -04:00:00 |
| %:::z | numeric time zone with : to necessary precision (e.g., -04, +05:30) | -04 |
| %Z | alphabetic time zone abbreviation (e.g., EDT) | EDT |
By default, date pads numeric fields with zeroes. By default, date pads numeric fields with zeroes.
The following optional flags may follow '%': The following optional flags may follow '%':
- (hyphen) do not pad the field * `-` (hyphen) do not pad the field
_ (underscore) pad with spaces * `_` (underscore) pad with spaces
0 (zero) pad with zeros * `0` (zero) pad with zeros
^ use upper case if possible * `^` use upper case if possible
# use opposite case if possible * `#` use opposite case if possible
After any flags comes an optional field width, as a decimal number; After any flags comes an optional field width, as a decimal number;
then an optional modifier, which is either then an optional modifier, which is either
@ -68,11 +69,19 @@ O to use the locale's alternate numeric symbols if available.
Examples: Examples:
Convert seconds since the epoch (1970-01-01 UTC) to a date Convert seconds since the epoch (1970-01-01 UTC) to a date
$ date --date='@2147483647'
```
date --date='@2147483647'
```
Show the time on the west coast of the US (use tzselect(1) to find TZ) Show the time on the west coast of the US (use tzselect(1) to find TZ)
$ TZ='America/Los_Angeles' date
```
TZ='America/Los_Angeles' date
```
Show the local time for 9AM next Friday on the west coast of the US Show the local time for 9AM next Friday on the west coast of the US
$ date --date='TZ="America/Los_Angeles" 09:00 next Fri'
```
date --date='TZ="America/Los_Angeles" 09:00 next Fri'
``` ```