strftime
-convert date and time to string
#include <time.h>
size_t *strftime (char *s, size_t maxsize, const char *format, const struct tm *timeptr);
strftime
places characters into the array pointed to by s
as controlled by the string pointed to by format
. The format
string consists of zero or more directives and ordinary characters. All ordinary characters (including the terminating null character) are copied unchanged into the array. For strftime
, no more than maxsize
characters are placed into the array.
If format
is (char *)0, then the locale's default format is used. The default format is the same as "%c"
.
Each directive is replaced by appropriate characters as described in the following list. The appropriate characters are determined by the LC_TIME
category of the program's locale and by the values contained in the structure pointed to by timeptr
.
The difference between If the total number of resulting characters including the terminating null character is not more than By default, the output of The timezone is taken from the environment variable The example illustrates the use of This results in %U
and %W
lies in which day is counted as the first of the week. Week number 01 is the first week in January starting with a Sunday for %U
or a Monday for %W
. Week number 00 contains those days before the first Sunday or Monday in January for %U
and %W
, respectively.
maxsize
, strftime
, returns the number of characters placed into the array pointed to by s
not including the terminating null character. Otherwise, zero is returned and the contents of the array are indeterminate.
Selecting the Output Language
strftime
, appears in US English. The user can request that the output of strftime
be in a specific language by setting the locale
for category
LC_TIME
in setlocale
(3).
Timezone
TZ
. See ctime
(3C) for a description of TZ
.
Examples
strftime
. It shows what the string in str
would look like if the structure pointed to by tmptr
contains the values corresponding to Thursday, August 28, 1986 at 12:44:36 in New Jersey.
strftime (str, strsize, "%A %b %d %j", tmptr)
str
containing "Thursday Aug 28 240".
Files
$TUXDIR/locale/
locale/LANGINFO
- file containing compiled locale-specific date and time information
See Also
mklanginfo
(1), setlocale
(3)