strptime(3C) strptime(3C)
strptime - date and time conversion
#include <time.h>
char *strptime (const char *buf, const char *format, struct tm *tm);
strptime converts the character string pointed to by buf to values which
are stored in the tm structure pointed to by tm, using the format
specified by format.
The format string consists of zero or more directives and ordinary
characters. Each directive is composed of one of the following: one or
more white-space characters (as specified by isspace(); an ordinary
character (neither % nor a white-space character); or a conversion
specification. Each conversion specification is composed of a % character
followed by a conversion character which specifies the replacement
required. There must be white-space or other non-alphanumeric characters
between any two conversion specifications. The following conversion
specifications are supported:
%% same as %
%a is the day of week, using the locale's weekday names; either
the abbreviated or full name may be specified.
%A is the same as %a.
%b is the month, using the locale's month names; either the
abbreviated or full name may be specified.
%B is the same as %b.
%c is replaced by the locale's appropriate date and time
representation.
%C is the century number [0,99]; leading zeros are permitted but
not required.
%d day of month ( 01 - 31 ); leading zeroes are permitted but not
required.
%D date as %m/%d/%y
%e is the same as %d.
%h is the same as %b.
%H is the hour (24-hour clock) ( 00 - 23 ); leading zeroes are
permitted but not required.
%I hour ( 01 - 12 )
%j day number of year ( 001 - 366 )
%m month number ( 01 - 12 )
%M minute ( 00 - 59 )
%n is any white space.
%p locale's equivalent of either AM or PM
%r time as %I:%M:%S %p [AM|PM]
%R time as %H:%M
%S seconds ( 00 - 61 ), allows for leap seconds
Page 1
strptime(3C) strptime(3C)
%t is any white space.
%T time as %H:%M:%S
%U week number of year ( 00 - 53 ), Sunday is the first day of
week 1
%w weekday number ( 0 - 6 ), Sunday = 0
%W week number of year ( 00 - 53 ), Monday is the first day of
week 1
%x locale's appropriate date representation
%X locale's appropriate time representation
%y year within century ( 00 - 99 )
%Y year as ccyy ( e.g. 1986)
The difference between %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.
Selecting the Output's Language
By default, the output of strptime appears in U.S. English. The user can
request that the output of strptime be in a specific language by setting
the locale for category <b>LC_TIME in setlocale.
Timezone [Toc] [Back]
The timezone is taken from the environment variable TZ [see ctime(3C) for
a description of TZ].
Upon successful completion, strptime() returns a pointer to the character
following the last character parsed. Otherwise, a null pointer is
returned.
/usr/lib/locale/locale<b>/LC_TIME - file containing locale-specific date and
time information
time(2), ctime(3C), strftime(3C), getenv(3C), setlocale(3C), timezone(4),
environ(5).
PPPPaaaaggggeeee 2222 [ Back ]
|