]>
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 | .\" |
e8426ca2 | 37 | .TH STRFTIME 3 2020-04-11 "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 .) | |
a748a16a ES |
92 | (The specific names used in the current locale can be obtained by calling |
93 | .BR nl_langinfo (3) | |
9c85099e | 94 | with |
a748a16a ES |
95 | .BR ABDAY_ { 1 \(en 7 } |
96 | as an argument.) | |
fea681da MK |
97 | .TP |
98 | .B %A | |
32afd197 | 99 | The full name of the day of the week according to the current locale. |
fca67dd0 MK |
100 | (Calculated from |
101 | .IR tm_wday .) | |
a748a16a ES |
102 | (The specific names used in the current locale can be obtained by calling |
103 | .BR nl_langinfo (3) | |
9c85099e | 104 | with |
a748a16a ES |
105 | .BR DAY_ { 1 \(en 7 } |
106 | as an argument.) | |
fea681da MK |
107 | .TP |
108 | .B %b | |
109 | The abbreviated month name according to the current locale. | |
fca67dd0 MK |
110 | (Calculated from |
111 | .IR tm_mon .) | |
a748a16a ES |
112 | (The specific names used in the current locale can be obtained by calling |
113 | .BR nl_langinfo (3) | |
9c85099e | 114 | with |
a748a16a ES |
115 | .BR ABMON_ { 1 \(en 12 } |
116 | as an argument.) | |
fea681da MK |
117 | .TP |
118 | .B %B | |
119 | The full month name according to the current locale. | |
fca67dd0 MK |
120 | (Calculated from |
121 | .IR tm_mon .) | |
a748a16a ES |
122 | (The specific names used in the current locale can be obtained by calling |
123 | .BR nl_langinfo (3) | |
9c85099e | 124 | with |
a748a16a ES |
125 | .BR MON_ { 1 \(en 12 } |
126 | as an argument.) | |
fea681da MK |
127 | .TP |
128 | .B %c | |
129 | The preferred date and time representation for the current locale. | |
a748a16a ES |
130 | (The specific format used in the current locale can be obtained by calling |
131 | .BR nl_langinfo (3) | |
9c85099e | 132 | with |
a748a16a ES |
133 | .B D_T_FMT |
134 | as an argument for the | |
135 | .B %c | |
136 | conversion specification, and with | |
137 | .B ERA_D_T_FMT | |
138 | for the | |
139 | .B %Ec | |
140 | conversion specification.) | |
cb573e41 ES |
141 | (In the POSIX locale this is equivalent to |
142 | .BR "%a %b %e %H:%M:%S %Y" .) | |
fea681da MK |
143 | .TP |
144 | .B %C | |
145 | The century number (year/100) as a 2-digit integer. (SU) | |
b0f9cb5e ES |
146 | (The |
147 | .B %EC | |
148 | conversion specification corresponds to the name of the era.) | |
fca67dd0 MK |
149 | (Calculated from |
150 | .IR tm_year .) | |
fea681da MK |
151 | .TP |
152 | .B %d | |
153 | The day of the month as a decimal number (range 01 to 31). | |
fca67dd0 MK |
154 | (Calculated from |
155 | .IR tm_mday .) | |
fea681da MK |
156 | .TP |
157 | .B %D | |
5adafd6d MK |
158 | Equivalent to |
159 | .BR %m/%d/%y . | |
5503c85e | 160 | (Yecch\(emfor Americans only. |
5adafd6d | 161 | Americans should note that in other countries |
0daa9e92 | 162 | .B %d/%m/%y |
5adafd6d | 163 | is rather common. |
c13182ef | 164 | This means that in international context this format is |
fea681da MK |
165 | ambiguous and should not be used.) (SU) |
166 | .TP | |
167 | .B %e | |
5adafd6d MK |
168 | Like |
169 | .BR %d , | |
170 | the day of the month as a decimal number, but a leading | |
fea681da | 171 | zero is replaced by a space. (SU) |
fca67dd0 MK |
172 | (Calculated from |
173 | .IR tm_mday .) | |
fea681da MK |
174 | .TP |
175 | .B %E | |
b0f9cb5e | 176 | Modifier: use alternative ("era-based") format, see below. (SU) |
fea681da MK |
177 | .TP |
178 | .B %F | |
5adafd6d MK |
179 | Equivalent to |
180 | .B %Y-%m-%d | |
590d0346 | 181 | (the ISO\ 8601 date format). (C99) |
fea681da MK |
182 | .TP |
183 | .B %G | |
590d0346 | 184 | The ISO\ 8601 week-based year (see NOTES) with century as a decimal number. |
5adafd6d MK |
185 | The 4-digit year corresponding to the ISO week number (see |
186 | .BR %V ). | |
187 | This has the same format and value as | |
3d78d778 | 188 | .BR %Y , |
590d0346 | 189 | except that if the ISO week number belongs to the previous or next year, |
fea681da | 190 | that year is used instead. (TZ) |
fca67dd0 MK |
191 | (Calculated from |
192 | .IR tm_year , | |
193 | .IR tm_yday , | |
194 | and | |
195 | .IR tm_wday .) | |
fea681da MK |
196 | .TP |
197 | .B %g | |
5adafd6d MK |
198 | Like |
199 | .BR %G , | |
9bc87ed0 | 200 | but without century, that is, with a 2-digit year (00\(en99). (TZ) |
fca67dd0 MK |
201 | (Calculated from |
202 | .IR tm_year , | |
203 | .IR tm_yday , | |
204 | and | |
205 | .IR tm_wday .) | |
fea681da MK |
206 | .TP |
207 | .B %h | |
5adafd6d MK |
208 | Equivalent to |
209 | .BR %b . | |
210 | (SU) | |
fea681da MK |
211 | .TP |
212 | .B %H | |
213 | The hour as a decimal number using a 24-hour clock (range 00 to 23). | |
fca67dd0 MK |
214 | (Calculated from |
215 | .IR tm_hour .) | |
fea681da MK |
216 | .TP |
217 | .B %I | |
218 | The hour as a decimal number using a 12-hour clock (range 01 to 12). | |
fca67dd0 MK |
219 | (Calculated from |
220 | .IR tm_hour .) | |
fea681da MK |
221 | .TP |
222 | .B %j | |
223 | The day of the year as a decimal number (range 001 to 366). | |
fca67dd0 MK |
224 | (Calculated from |
225 | .IR tm_yday .) | |
fea681da MK |
226 | .TP |
227 | .B %k | |
228 | The hour (24-hour clock) as a decimal number (range 0 to 23); | |
6387216b MK |
229 | single digits are preceded by a blank. |
230 | (See also | |
5adafd6d | 231 | .BR %H .) |
fca67dd0 MK |
232 | (Calculated from |
233 | .IR tm_hour .) | |
5adafd6d | 234 | (TZ) |
fea681da MK |
235 | .TP |
236 | .B %l | |
237 | The hour (12-hour clock) as a decimal number (range 1 to 12); | |
6387216b MK |
238 | single digits are preceded by a blank. |
239 | (See also | |
5adafd6d | 240 | .BR %I .) |
fca67dd0 MK |
241 | (Calculated from |
242 | .IR tm_hour .) | |
5adafd6d | 243 | (TZ) |
fea681da MK |
244 | .TP |
245 | .B %m | |
246 | The month as a decimal number (range 01 to 12). | |
fca67dd0 MK |
247 | (Calculated from |
248 | .IR tm_mon .) | |
fea681da MK |
249 | .TP |
250 | .B %M | |
251 | The minute as a decimal number (range 00 to 59). | |
fca67dd0 MK |
252 | (Calculated from |
253 | .IR tm_min .) | |
fea681da MK |
254 | .TP |
255 | .B %n | |
256 | A newline character. (SU) | |
257 | .TP | |
258 | .B %O | |
b0f9cb5e | 259 | Modifier: use alternative numeric symbols, see below. (SU) |
fea681da MK |
260 | .TP |
261 | .B %p | |
f8a07a21 | 262 | Either "AM" or "PM" according to the given time value, or the |
fea681da | 263 | corresponding strings for the current locale. |