]> git.ipfire.org Git - thirdparty/man-pages.git/blame - man3/strftime.3
stime.2, time.2, utimensat.2, ctime.3, difftime.3, ftime.3, getspnam.3, mq_receive...
[thirdparty/man-pages.git] / man3 / strftime.3
CommitLineData
fea681da
MK
1.\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk)
2.\"
3.\" Permission is granted to make and distribute verbatim copies of this
4.\" manual provided the copyright notice and this permission notice are
5.\" preserved on all copies.
6.\"
7.\" Permission is granted to copy and distribute modified versions of this
8.\" manual under the conditions for verbatim copying, provided that the
9.\" entire resulting derived work is distributed under the terms of a
10.\" permission notice identical to this one.
c13182ef 11.\"
fea681da
MK
12.\" Since the Linux kernel and libraries are constantly changing, this
13.\" manual page may be incorrect or out-of-date. The author(s) assume no
14.\" responsibility for errors or omissions, or for damages resulting from
15.\" the use of the information contained herein. The author(s) may not
16.\" have taken the same level of care in the production of this manual,
17.\" which is licensed free of charge, as they might when working
18.\" professionally.
c13182ef 19.\"
fea681da
MK
20.\" Formatted or processed versions of this manual, if unaccompanied by
21.\" the source, must acknowledge the copyright and authors of this work.
22.\"
23.\" References consulted:
24.\" Linux libc source code
25.\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991)
26.\" 386BSD man pages
27.\" GNU texinfo documentation on glibc date/time functions.
28.\" Modified Sat Jul 24 18:03:44 1993 by Rik Faith (faith@cs.unc.edu)
29.\" Applied fix by Wolfgang Franke, aeb, 961011
30.\" Corrected return value, aeb, 970307
31.\" Added Single Unix Spec conversions and %z, aeb/esr, 990329.
d597239c 32.\" 2005-11-22 mtk, added Glibc Notes covering optional 'flag' and
a4020d9c 33.\" 'width' components of conversion specifications.
fea681da 34.\"
f37678fe 35.TH STRFTIME 3 2010-01-17 "GNU" "Linux Programmer's Manual"
fea681da
MK
36.SH NAME
37strftime \- format date and time
38.SH SYNOPSIS
39.nf
40.B #include <time.h>
41.sp
42.BI "size_t strftime(char *" s ", size_t " max ", const char *" format ,
b9f02710 43.BI " const struct tm *" tm );
fea681da
MK
44.fi
45.SH DESCRIPTION
60a90ecd
MK
46The
47.BR strftime ()
48function formats the broken-down time \fItm\fP
fea681da
MK
49according to the format specification \fIformat\fP and places the
50result in the character array \fIs\fP of size \fImax\fP.
e6068f21
MK
51.\" FIXME POSIX says: Local timezone information is used as though
52.\" strftime() called tzset(). But this doesn't appear to be the case
fea681da
MK
53.PP
54Ordinary characters placed in the format string are copied to \fIs\fP
c13182ef 55without conversion.
a4020d9c 56.I "Conversion specifications"
f81fb444 57are introduced by a \(aq%\(aq
c13182ef 58character, and terminated by a
a4020d9c
MK
59.IR "conversion specifier character" ,
60and are replaced in \fIs\fP as follows:
fea681da
MK
61.TP
62.B %a
63The abbreviated weekday name according to the current locale.
64.TP
65.B %A
66The full weekday name according to the current locale.
67.TP
68.B %b
69The abbreviated month name according to the current locale.
70.TP
71.B %B
72The full month name according to the current locale.
73.TP
74.B %c
75The preferred date and time representation for the current locale.
76.TP
77.B %C
78The century number (year/100) as a 2-digit integer. (SU)
79.TP
80.B %d
81The day of the month as a decimal number (range 01 to 31).
82.TP
83.B %D
5adafd6d
MK
84Equivalent to
85.BR %m/%d/%y .
86(Yecch \(em for Americans only.
87Americans should note that in other countries
0daa9e92 88.B %d/%m/%y
5adafd6d 89is rather common.
c13182ef 90This means that in international context this format is
fea681da
MK
91ambiguous and should not be used.) (SU)
92.TP
93.B %e
5adafd6d
MK
94Like
95.BR %d ,
96the day of the month as a decimal number, but a leading
fea681da
MK
97zero is replaced by a space. (SU)
98.TP
99.B %E
100Modifier: use alternative format, see below. (SU)
101.TP
102.B %F
5adafd6d
MK
103Equivalent to
104.B %Y-%m-%d
590d0346 105(the ISO\ 8601 date format). (C99)
fea681da
MK
106.TP
107.B %G
590d0346 108The ISO\ 8601 week-based year (see NOTES) with century as a decimal number.
5adafd6d
MK
109The 4-digit year corresponding to the ISO week number (see
110.BR %V ).
111This has the same format and value as
3d78d778 112.BR %Y ,
590d0346 113except that if the ISO week number belongs to the previous or next year,
fea681da
MK
114that year is used instead. (TZ)
115.TP
116.B %g
5adafd6d
MK
117Like
118.BR %G ,
119but without century, that is, with a 2-digit year (00-99). (TZ)
fea681da
MK
120.TP
121.B %h
5adafd6d
MK
122Equivalent to
123.BR %b .
124(SU)
fea681da
MK
125.TP
126.B %H
127The hour as a decimal number using a 24-hour clock (range 00 to 23).
128.TP
129.B %I
130The hour as a decimal number using a 12-hour clock (range 01 to 12).
131.TP
132.B %j
133The day of the year as a decimal number (range 001 to 366).
134.TP
135.B %k
136The hour (24-hour clock) as a decimal number (range 0 to 23);
6387216b
MK
137single digits are preceded by a blank.
138(See also
5adafd6d
MK
139.BR %H .)
140(TZ)
fea681da
MK
141.TP
142.B %l
143The hour (12-hour clock) as a decimal number (range 1 to 12);
6387216b
MK
144single digits are preceded by a blank.
145(See also
5adafd6d
MK
146.BR %I .)
147(TZ)
fea681da
MK
148.TP
149.B %m
150The month as a decimal number (range 01 to 12).
151.TP
152.B %M
153The minute as a decimal number (range 00 to 59).
154.TP
155.B %n
156A newline character. (SU)
157.TP
158.B %O
159Modifier: use alternative format, see below. (SU)
160.TP
161.B %p
f8a07a21 162Either "AM" or "PM" according to the given time value, or the
fea681da 163corresponding strings for the current locale.