INTERNATIONAL VERSION
Page 1 (printed 6/20/89)
STRFTIME(S) UNIX System V STRFTIME(S)
Name
strftime - format date/time string
Syntax
#include <time.h>
int strftime(s, maxsize, format, timeptr)
char *s;
int maxsize;
char *format;
struct tm *timeptr;
Description
The strftime function places its output (according to the
format string format and the time values contained in the
structure pointed to by timeptr), followed by the null
character (\0) in consecutive bytes starting at s. The
maximum length of the output string is specified by maxsize,
the maximum number of characters including the terminating
null character.
The strftime function converts and formats the time values
contained in the structure pointed to by timeptr under
control of the format string format. The string format is a
character string can contain two types of object. These are:
plain characters, which are simply copied to the output
string, and directives.
Each directive is introduced by the percent character (%).
The following directives are independent of the program's
current locale (see locale(M)):
%d is replaced by the day of the month as a decimal number
(01-31)
%H is replaced by the hour (24-hour clock) as a decimal
number (00-23)
%I is replaced by the hour (12-hour clock) as a decimal
number (01-12)
%j is replaced by the day of the year as a decimal number
(001-366)
%m is replaced by the month as a decimal number (01-12)
%M is replaced by the minute as a decimal number (00-59)
%S is replaced by the second as a decimal number (00-59)
%U is replaced by the week number of the year (Sunday as the
first day of the week) as a decimal number (00-52)
%w is replaced by the weekday as a decimal number
[0(Sunday)-6]
%W is replaced by the week number of the year (Monday as the
first day of the week) as a decimal number (00-52)
%y is replaced by the year without century as a decimal
number (00-99)
%Y is replaced by the year with century as a decimal number
%Z is replaced by the timezone name, or by no characters if
no timezone exists
%% is replaced by %
The strings used to replace the following directives are
dependent on the program's current locale, and are defined
using the utility timtbl(M)):
%a is replaced by the locale's abbreviated weekday name
%A is replaced by the locale's full weekday name
%b is replaced by the locale's abbreviated month name
%B is replaced by the locale's full month name
%c is replaced by the locale's appropriate date and time
representation
%p is replaced by the locale's equivalent of AM or PM
%x is replaced by the locale's appropriate date
representation
%X is replaced by the locale's appropriate time
representation
Return Value
The function returns the number of characters placed in the
string s (not including the terminating null character), or
zero if the length of the output string would exceed
maxsize. In the latter case, the content of the output
string s is undefined.
Zero is also returned if the function detects a situation
which would lead to infinite recursion; for example, if a
format string refers to itself.
See Also
timtbl(M), ctime(S), nl_cxtime(S)
Standards Conformance
strftime is conformant with:
ANSI X3.159-198X C Language Draft Standard, May 13, 1988;
IEEE POSIX Std 1003.1-1988 with C Standard Language-
Dependent System Support;
and NIST FIPS 151-1.
(printed 6/20/89)