strftime.3c (2010 09)

s
strftime(3C) strftime(3C)
NAME
strftime() - convert date and time to string
SYNOPSIS
#include <time.h>
size_t strftime(
char *s,
size_t maxsize,
const char *format,
const struct tm *timeptr
);
DESCRIPTION
The strftime() function converts the contents of a
tm structure (see ctime (3C)) to a formatted date
and time string.
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. A directive con-
sists of a
% character, an optional field width and precision specification, and a terminating character that
determines the directive’s behavior. All ordinary characters (including the terminating null character are
copied unchanged into the array. No more than maxsize characters are placed into the array. Each
directive is replaced by the appropriate characters as described in the following list. The appropriate
characters are determined by the program’s locale, by the values contained in the structure pointed to by
timeptr , and by the TZ environment variable (see External Influences below).
Directives
The following directives, shown without the optional field width and precision specification, are replaced
by the indicated characters:
%a Locale’s abbreviated weekday name.
%A Locale’s full weekday name.
%b Locale’s abbreviated month name.
%B Locale’s full month name.
%c Locale’s appropriate date and time representation.
%C The century number (the year divided by 100 and truncated to an integer) as a decimal
number [00-99].
%d Day of the month as a decimal number [01,31].
%D Equivalent to the directive string %m/%d/%y.
%e Day of the month as a decimal number [1,31]; a single digit is preceded by a space.
%F Equivalent to the directive string %Y-%m-%d(the ISO 8601:2000 standard date for-
mat)
%g Last 2 digits of the week-based year as a decimal number [00,99].
%G Week-based year as a decimal number (for example, 1977).
%h Equivalent to %b.
%H Hour (24-hour clock) as a decimal number [00,23].
%I Hour (12-hour clock) as a decimal number [01,12].
%j Day of the year as a decimal number [001,366].
%m Month as a decimal number [01,12].
%M Minute as a decimal number [00,59].
%n The New-line character.
%p Locale’s equivalent of either AM or PM.
%r The time in AM and PM notation; in the POSIX locale this is equivalent to %I:%M:%S
%p.
%R The time in 24 hour notation (%H:%M).
%S Second as a decimal number [00,61].
%t The Tab character.
%T The time in hours, minutes, and seconds (%H:%M:%S).
%u The weekday as a decimal number [1(Monday),7].
%U Week number of the year (Sunday as the first day of the week) as a decimal number
[00,53]. All days in a new year preceding the first Sunday are considered to be in week 0.
%V The week number of the year (Monday as the first day of the week) as a decimal number
[01,53]. If the week containing January 1st has four or more days in the new year, then
it is considered week 1; otherwise, it is the last week of the previous year, and the next
HP-UX 11i Version 3: September 2010 − 1 − Hewlett-Packard Company 1