STRFTIME(3) BSD Programmer's Manual STRFTIME(3)NAMEstrftime - format date and time
SYNOPSIS
#include <time.h>
size_t
strftime(char *buf, size_t maxsize, const char *format,
const struct tm *timeptr);
DESCRIPTION
The strftime() function formats the information from timeptr into the
buffer buf according to the string pointed to by format.
The format string consists of zero or more conversion specifications and
ordinary characters. All ordinary characters are copied directly into
the buffer. A conversion specification consists of a ``%'' character and
one other character.
No more than maxsize characters will be placed into the array. If the
total number of resulting characters, including the terminating null
character, is not more than maxsize, strftime() returns the number of
characters in the array, not counting the terminating null. Otherwise,
zero is returned.
Each conversion specification is replaced by the characters as follows
which are then copied into the buffer.
%a is replaced by the locale's abbreviated weekday name. In the de-
fault locale, it is equivalent to one of the following: ``Sun'',
``Mon'', ``Tue'', ``Wed'', ``Thu'', ``Fri'' or ``Sat''.
%A is replaced by the locale's full weekday name. In the default lo-
cale, it is equivalent to one of the following: ``Sunday'',
``Monday'', ``Tuesday'', ``Wednesday'', ``Thursday'', ``Friday'',
or ``Saturday''.
%b is replaced by the locale's abbreviated month name. In the default
locale, it is equivalent to one of the following: ``Jan'', ``Feb'',
``Mar'', ``Apr'', ``May'', ``Jun'', ``Jul'', ``Aug'', ``Sep'',
``Oct'', ``Nov'' or ``Dec''.
%B is replaced by the locale's full month name. In the default lo-
cale, it is equivalent to one of the following: ``January'',
``February'', ``March'', ``April'', ``May'', ``June'', ``July'',
``August'', ``September'', ``October'', ``November'' or
``December''.
%c is replaced by the locale's date and time representation. In the
default locale, it is equivalent to ``%x %X'', i.e., ``mm/dd/yy
hh:mm:ss''.
%C is replaced by the century (a year divided by 100 and truncated to
an integer) as a decimal number (00-99).
%d is replaced by the day of the month as a decimal number (01-31).
%D is equivalent to ``%m/%d/%y'', i.e ``mm/dd/yy''.
%e is replaced by the day of month as a decimal number (1-31); single
digits are preceded by a blank.
%h is replaced by the locale's abbreviated month name. In the default
locale, it is equivalent to one of the following: ``Jan'', ``Feb'',
``Mar'', ``Apr'', ``May'', ``Jun'', ``Jul'', ``Aug'', ``Sep'',
``Oct'', ``Nov'' or ``Dec''.
%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).
%k is replaced by the hour (24-hour clock) as a decimal number (0-23);
single digits are preceded by a blank.
%l is replaced by the hour (12-hour clock) as a decimal number (1-12);
single digits are preceded by a blank.
%m is replaced by the month as a decimal number (01-12).
%M is replaced by the minute as a decimal number (00-59).
%n is replaced by a newline.
%p is replaced by locale's equivalent of ``AM'' (ante meridiem) or
``PM'' (post meridiem) as appropriate. In the default locale, it
is replaced by ``AM'' or ``PM''.
%r is equivalent to ``%I:%M:%S %p'', i.e., ``hh:mm:ss AM|PM''.
%R is equivalent to ``%H:%M'', i.e., ``hh:mm''.
%s is replaced by the number of seconds since the Epoch, UCT (see
mktime(3)).
%S is replaced by the second as a decimal number (00-60).
%t is replaced by a tab.
%T is equivalent to ``%H:%M:%S'', i.e., ``hh:mm:ss''.
%u is replaced by the weekday (Monday as the first day of the week) as
a decimal number (1-7).
%U is replaced by the week number of the year (the first Sunday as the
first day of week 1) as a decimal number (00-53).
%V is replaced by the week number of the year (the first Monday as the
first day of week 1) as a decimal number (00-53).
%w is replaced by the weekday (Sunday as the first day of the week) as
a decimal number (0-6).
%W is replaced by the week number of the year (the first Monday as the
first day of week 1) as a decimal number (00-53).
%x is replaced by the locale's date representation. In the default
locale, it is equivalent to ``%m/%d/%y'', i.e., ``mm/dd/yy''.
%X is replaced by the locale's time representation. In the default
locale, it is equivalent to ``%H:%M:%S'', i.e., ``hh:mm:ss''.
%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 time zone name.
%% is replaced by a single % character.
SEE ALSOdate(1), printf(1), ctime(3), printf(3)STANDARDS
The strftime() function conforms to ANSI C X3.159-1989 (``ANSI C ''). The
%C, %D, %e, %h, %k, %l, %n, %r, %R, %s, %t, %T, %u and %V conversion
specifications are extensions to that standard.
BUGS
There is no conversion specification for the phase of the moon.
BSDI BSD/OS June 4, 1993 3