]>
Commit | Line | Data |
---|---|---|
fea681da MK |
1 | .\" Copyright 1993 David Metcalfe (david@prism.demon.co.uk) |
2 | .\" | |
93015253 | 3 | .\" %%%LICENSE_START(VERBATIM) |
fea681da MK |
4 | .\" Permission is granted to make and distribute verbatim copies of this |
5 | .\" manual provided the copyright notice and this permission notice are | |
6 | .\" preserved on all copies. | |
7 | .\" | |
8 | .\" Permission is granted to copy and distribute modified versions of this | |
9 | .\" manual under the conditions for verbatim copying, provided that the | |
10 | .\" entire resulting derived work is distributed under the terms of a | |
11 | .\" permission notice identical to this one. | |
c13182ef | 12 | .\" |
fea681da MK |
13 | .\" Since the Linux kernel and libraries are constantly changing, this |
14 | .\" manual page may be incorrect or out-of-date. The author(s) assume no | |
15 | .\" responsibility for errors or omissions, or for damages resulting from | |
16 | .\" the use of the information contained herein. The author(s) may not | |
17 | .\" have taken the same level of care in the production of this manual, | |
18 | .\" which is licensed free of charge, as they might when working | |
19 | .\" professionally. | |
c13182ef | 20 | .\" |
fea681da MK |
21 | .\" Formatted or processed versions of this manual, if unaccompanied by |
22 | .\" the source, must acknowledge the copyright and authors of this work. | |
4b72fb64 | 23 | .\" %%%LICENSE_END |
fea681da MK |
24 | .\" |
25 | .\" References consulted: | |
26 | .\" Linux libc source code | |
27 | .\" Lewine's _POSIX Programmer's Guide_ (O'Reilly & Associates, 1991) | |
28 | .\" 386BSD man pages | |
29 | .\" GNU texinfo documentation on glibc date/time functions. | |
30 | .\" Modified Sat Jul 24 18:03:44 1993 by Rik Faith (faith@cs.unc.edu) | |
31 | .\" Applied fix by Wolfgang Franke, aeb, 961011 | |
32 | .\" Corrected return value, aeb, 970307 | |
008f1ecc | 33 | .\" Added Single UNIX Spec conversions and %z, aeb/esr, 990329. |
d597239c | 34 | .\" 2005-11-22 mtk, added Glibc Notes covering optional 'flag' and |
a4020d9c | 35 | .\" 'width' components of conversion specifications. |
fea681da | 36 | .\" |
4b8c67d9 | 37 | .TH STRFTIME 3 2017-09-15 "GNU" "Linux Programmer's Manual" |
fea681da MK |
38 | .SH NAME |
39 | strftime \- format date and time | |
40 | .SH SYNOPSIS | |
41 | .nf | |
42 | .B #include <time.h> | |
68e4db0a | 43 | .PP |
fea681da | 44 | .BI "size_t strftime(char *" s ", size_t " max ", const char *" format , |
b9f02710 | 45 | .BI " const struct tm *" tm ); |
fea681da MK |
46 | .fi |
47 | .SH DESCRIPTION | |
60a90ecd MK |
48 | The |
49 | .BR strftime () | |
46d8df8e MK |
50 | function formats the broken-down time |
51 | .I tm | |
52 | according to the format specification | |
53 | .I format | |
54 | and places the | |
55 | result in the character array | |
56 | .I s | |
57 | of size | |
58 | .IR max . | |
8dc9c2d6 MK |
59 | The broken-down time structure |
60 | .I tm | |
61 | is defined in | |
62 | .IR <time.h> . | |
63 | See also | |
64 | .BR ctime (3). | |
bea08fec | 65 | .\" FIXME . POSIX says: Local timezone information is used as though |
e6068f21 | 66 | .\" strftime() called tzset(). But this doesn't appear to be the case |
fea681da | 67 | .PP |
db74fcdd MW |
68 | The format specification is a null-terminated string and may contain |
69 | special character sequences called | |
70 | .IR "conversion specifications", | |
71 | each of which is introduced by a \(aq%\(aq character and terminated by | |
72 | some other character known as a | |
73 | .IR "conversion specifier character". | |
74 | All other character sequences are | |
75 | .IR "ordinary character sequences". | |
76 | .PP | |
77 | The characters of ordinary character sequences (including the null byte) | |
46d8df8e MK |
78 | are copied verbatim from |
79 | .I format | |
80 | to | |
81 | .IR s . | |
4175f999 | 82 | However, the characters |
1754f8d0 | 83 | of conversion specifications are replaced as shown in the list below. |
fca67dd0 MK |
84 | In this list, the field(s) employed from the |
85 | .I tm | |
86 | structure are also shown. | |
fea681da MK |
87 | .TP |
88 | .B %a | |
32afd197 | 89 | The abbreviated name of the day of the week according to the current locale. |
fca67dd0 MK |
90 | (Calculated from |
91 | .IR tm_wday .) | |
fea681da MK |
92 | .TP |
93 | .B %A | |
32afd197 | 94 | The full name of the day of the week according to the current locale. |
fca67dd0 MK |
95 | (Calculated from |
96 | .IR tm_wday .) | |
fea681da MK |
97 | .TP |
98 | .B %b | |
99 | The abbreviated month name according to the current locale. | |
fca67dd0 MK |
100 | (Calculated from |
101 | .IR tm_mon .) | |
fea681da MK |
102 | .TP |
103 | .B %B | |
104 | The full month name according to the current locale. | |
fca67dd0 MK |
105 | (Calculated from |
106 | .IR tm_mon .) | |
fea681da MK |
107 | .TP |
108 | .B %c | |
109 | The preferred date and time representation for the current locale. | |
110 | .TP | |
111 | .B %C | |
112 | The century number (year/100) as a 2-digit integer. (SU) | |
fca67dd0 MK |
113 | (Calculated from |
114 | .IR tm_year .) | |
fea681da MK |
115 | .TP |
116 | .B %d | |
117 | The day of the month as a decimal number (range 01 to 31). | |
fca67dd0 MK |
118 | (Calculated from |
119 | .IR tm_mday .) | |
fea681da MK |
120 | .TP |
121 | .B %D | |
5adafd6d MK |
122 | Equivalent to |
123 | .BR %m/%d/%y . | |
5503c85e | 124 | (Yecch\(emfor Americans only. |
5adafd6d | 125 | Americans should note that in other countries |
0daa9e92 | 126 | .B %d/%m/%y |
5adafd6d | 127 | is rather common. |
c13182ef | 128 | This means that in international context this format is |
fea681da MK |
129 | ambiguous and should not be used.) (SU) |
130 | .TP | |
131 | .B %e | |
5adafd6d MK |
132 | Like |
133 | .BR %d , | |
134 | the day of the month as a decimal number, but a leading | |
fea681da | 135 | zero is replaced by a space. (SU) |
fca67dd0 MK |
136 | (Calculated from |
137 | .IR tm_mday .) | |
fea681da MK |
138 | .TP |
139 | .B %E | |
140 | Modifier: use alternative format, see below. (SU) | |
141 | .TP | |
142 | .B %F | |
5adafd6d MK |
143 | Equivalent to |
144 | .B %Y-%m-%d | |
590d0346 | 145 | (the ISO\ 8601 date format). (C99) |
fea681da MK |
146 | .TP |
147 | .B %G | |
590d0346 | 148 | The ISO\ 8601 week-based year (see NOTES) with century as a decimal number. |
5adafd6d MK |
149 | The 4-digit year corresponding to the ISO week number (see |
150 | .BR %V ). | |
151 | This has the same format and value as | |
3d78d778 | 152 | .BR %Y , |
590d0346 | 153 | except that if the ISO week number belongs to the previous or next year, |
fea681da | 154 | that year is used instead. (TZ) |
fca67dd0 MK |
155 | (Calculated from |
156 | .IR tm_year , | |
157 | .IR tm_yday , | |
158 | and | |
159 | .IR tm_wday .) | |
fea681da MK |
160 | .TP |
161 | .B %g | |
5adafd6d MK |
162 | Like |
163 | .BR %G , | |
9bc87ed0 | 164 | but without century, that is, with a 2-digit year (00\(en99). (TZ) |
fca67dd0 MK |
165 | (Calculated from |
166 | .IR tm_year , | |
167 | .IR tm_yday , | |
168 | and | |
169 | .IR tm_wday .) | |
fea681da MK |
170 | .TP |
171 | .B %h | |
5adafd6d MK |
172 | Equivalent to |
173 | .BR %b . | |
174 | (SU) | |
fea681da MK |
175 | .TP |
176 | .B %H | |
177 | The hour as a decimal number using a 24-hour clock (range 00 to 23). | |
fca67dd0 MK |
178 | (Calculated from |
179 | .IR tm_hour .) | |
fea681da MK |
180 | .TP |
181 | .B %I | |
182 | The hour as a decimal number using a 12-hour clock (range 01 to 12). | |
fca67dd0 MK |
183 | (Calculated from |
184 | .IR tm_hour .) | |
fea681da MK |
185 | .TP |
186 | .B %j | |
187 | The day of the year as a decimal number (range 001 to 366). | |
fca67dd0 MK |
188 | (Calculated from |
189 | .IR tm_yday .) | |
fea681da MK |
190 | .TP |
191 | .B %k | |
192 | The hour (24-hour clock) as a decimal number (range 0 to 23); | |
6387216b MK |
193 | single digits are preceded by a blank. |
194 | (See also | |
5adafd6d | 195 | .BR %H .) |
fca67dd0 MK |
196 | (Calculated from |
197 | .IR tm_hour .) | |
5adafd6d | 198 | (TZ) |
fea681da MK |
199 | .TP |
200 | .B %l | |
201 | The hour (12-hour clock) as a decimal number (range 1 to 12); | |
6387216b MK |
202 | single digits are preceded by a blank. |
203 | (See also | |
5adafd6d | 204 | .BR %I .) |
fca67dd0 MK |
205 | (Calculated from |
206 | .IR tm_hour .) | |
5adafd6d | 207 | (TZ) |
fea681da MK |
208 | .TP |
209 | .B %m | |
210 | The month as a decimal number (range 01 to 12). | |
fca67dd0 MK |
211 | (Calculated from |
212 | .IR tm_mon .) | |
fea681da MK |
213 | .TP |
214 | .B %M | |
215 | The minute as a decimal number (range 00 to 59). | |
fca67dd0 MK |
216 | (Calculated from |
217 | .IR tm_min .) | |
fea681da MK |
218 | .TP |
219 | .B %n | |
220 | A newline character. (SU) | |
221 | .TP | |
222 | .B %O | |
223 | Modifier: use alternative format, see below. (SU) | |
224 | .TP | |
225 | .B %p | |
f8a07a21 | 226 | Either "AM" or "PM" according to the given time value, or the |
fea681da | 227 | corresponding strings for the current locale. |