5.7 Format Strings
20240407
A common standard (based on strftime) for specifying a date format
string will replace any %X
special characters with specific
components from the date (and time). For example, based on the result
of a call to the function lubridate::now(), which is
Thursday, 21 November 2024, 18:16:26 PM, the format
is %A, %e %B %Y, %H:%M:%S %p
.
The format strings that are available include:
%a
\(\longrightarrow\) Thu (3 char day name)%A
\(\longrightarrow\) Thursday (full day name)%b
\(\longrightarrow\) Nov (3 char month name)%B
\(\longrightarrow\) November (full month name)%d
\(\longrightarrow\) 21 (01-31 leading 0 numeric day of month)%e
\(\longrightarrow\) 21 (1-31 numeric day of month)%H
\(\longrightarrow\) 18 (00-23 numeric 24 hours)%I
\(\longrightarrow\) 06 (01-11 numeric 12 hours)%-I
\(\longrightarrow\) 6 (1-11 numeric hours no leading 0)%m
\(\longrightarrow\) 11 (01-12 numeric month)%M
\(\longrightarrow\) 16 (00-59 numeric minutes)%p
\(\longrightarrow\) PM (AM,PM upper morning or afternoon)%P
\(\longrightarrow\) pm (am,pm lower morning or afternoon)%S
\(\longrightarrow\) 26 (00-60 numeric seconds)%-S
\(\longrightarrow\) 26 (0-60 numeric seconds no leading 0)%y
\(\longrightarrow\) 24 (00-99 2 digit year)%Y
\(\longrightarrow\) 2024 (4 digit year)%Z
\(\longrightarrow\) AEDT (time zone)
A good resource is Fabrizio Musacchio’s strftime Cheat Sheet
Your donation will support ongoing availability and give you access to the PDF version of this book. Desktop Survival Guides include Data Science, GNU/Linux, and MLHub. Books available on Amazon include Data Mining with Rattle and Essentials of Data Science. Popular open source software includes rattle, wajig, and mlhub. Hosted by Togaware, a pioneer of free and open source software since 1984. Copyright © 1995-2022 Graham.Williams@togaware.com Creative Commons Attribution-ShareAlike 4.0