Commit | Line | Data |
---|---|---|
00b602b8 KB |
1 | .\" Copyright (c) 1989 The Regents of the University of California. |
2 | .\" All rights reserved. | |
3 | .\" | |
4 | .\" Redistribution and use in source and binary forms are permitted | |
5 | .\" provided that the above copyright notice and this paragraph are | |
6 | .\" duplicated in all such forms and that any documentation, | |
7 | .\" advertising materials, and other materials related to such | |
8 | .\" distribution and use acknowledge that the software was developed | |
9 | .\" by the University of California, Berkeley. The name of the | |
10 | .\" University may not be used to endorse or promote products derived | |
11 | .\" from this software without specific prior written permission. | |
12 | .\" THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR | |
13 | .\" IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED | |
14 | .\" WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. | |
15 | .\" | |
14fd63d8 | 16 | .\" @(#)strftime.3 5.4 (Berkeley) %G% |
00b602b8 KB |
17 | .\" |
18 | .TH STRFTIME 3 "%Q" | |
19 | .AT 3 | |
20 | .SH NAME | |
21 | strftime \- format date and time | |
22 | .SH SYNOPSIS | |
23 | .nf | |
24 | .ft B | |
25 | #include <sys/types.h> | |
26 | #include <time.h> | |
27 | ||
28 | size_t | |
29 | strftime(char *s, size_t maxsize, const char *format, | |
30 | const struct tm *timeptr); | |
31 | .ft R | |
32 | .fi | |
33 | .SH DESCRIPTION | |
34 | The | |
35 | .I strftime | |
36 | function formats the information from | |
37 | .I timeptr | |
38 | into the buffer | |
39 | .I buf | |
40 | according to the string pointed to by | |
41 | .IR format . | |
42 | .PP | |
43 | The | |
44 | .I format | |
45 | string consists of zero or more conversion specifications and | |
46 | ordinary characters. | |
47 | All ordinary characters are copied directly into the buffer. | |
48 | A conversion specification consists of a percent sign (``%'') | |
49 | and one other character. | |
50 | .PP | |
51 | No more than | |
52 | .I maxsize | |
53 | characters will be placed into the array. | |
54 | If the total number of resulting characters, including the terminating | |
55 | null character, is not more than | |
56 | .IR maxsize , | |
57 | .I strftime | |
58 | returns the number of characters in the array, not counting the | |
59 | terminating null. | |
60 | Otherwise, zero is returned. | |
61 | .PP | |
62 | Each conversion specification is replaced by the characters as | |
63 | follows which are then copied into the buffer. | |
64 | .TP | |
65 | .B %A | |
66 | is replaced by the full weekday name. | |
67 | .TP | |
68 | .B %a | |
69 | is replaced by the abbreviated weekday name, where the abbreviation | |
70 | is the first three characters. | |
71 | .TP | |
72 | .B %B | |
73 | is replaced by the full month name. | |
74 | .TP | |
e386ba1e | 75 | .B %b or %h |
00b602b8 KB |
76 | is replaced by the abbreviated month name, where the abbreviation is |
77 | the first three characters. | |
78 | .TP | |
14fd63d8 KB |
79 | .B %C |
80 | is equivalent to ``%a %b %e %H:%M:%S %Y'' (the format produced by | |
81 | .IR asctime (3). | |
82 | .TP | |
00b602b8 | 83 | .B %c |
5a2e4b32 | 84 | is equivalent to ``%m/%d/%y''. |
00b602b8 | 85 | .TP |
e386ba1e KB |
86 | .B %D |
87 | is replaced by the date in the format ``mm/dd/yy''. | |
88 | .TP | |
00b602b8 KB |
89 | .B %d |
90 | is replaced by the day of the month as a decimal number (01-31). | |
91 | .TP | |
14fd63d8 KB |
92 | .B %e |
93 | is replaced by the day of month as a decimal number (1-31); single | |
94 | digits are preceded by a blank. | |
95 | .TP | |
00b602b8 KB |
96 | .B %H |
97 | is replaced by the hour (24-hour clock) as a decimal number (00-23). | |
98 | .TP | |
99 | .B %I | |
100 | is replaced by the hour (12-hour clock) as a decimal number (01-12). | |
101 | .TP | |
102 | .B %j | |
103 | is replaced by the day of the year as a decimal number (001-366). | |
104 | .TP | |
14fd63d8 KB |
105 | .B %k |
106 | is replaced by the hour (24-hour clock) as a decimal number (0-23); | |
107 | single digits are preceded by a blank. | |
108 | .TP | |
109 | .B %l | |
110 | is replaced by the hour (12-hour clock) as a decimal number (01-12); | |
111 | single digits are preceded by a blank. | |
112 | .TP | |
e386ba1e KB |
113 | .B %M |
114 | is replaced by the minute as a decimal number (00-59). | |
115 | .TP | |
00b602b8 KB |
116 | .B %m |
117 | is replaced by the month as a decimal number (01-12). | |
118 | .TP | |
e386ba1e KB |
119 | .B %n |
120 | is replaced by a newline. | |
00b602b8 KB |
121 | .TP |
122 | .B %p | |
123 | is replaced by either ``AM'' or ``PM'' as appropriate. | |
124 | .TP | |
e386ba1e KB |
125 | .B %R |
126 | is equivalent to ``%H:%M''. | |
127 | .TP | |
128 | .B %r | |
129 | is equivalent to ``%I:%M:%S %p''. | |
130 | .TP | |
131 | .B %t | |
132 | is replaced by a tab. | |
133 | .TP | |
00b602b8 KB |
134 | .B %S |
135 | is replaced by the second as a decimal number (00-60). | |
136 | .TP | |
e386ba1e KB |
137 | .B %T or %X |
138 | is equivalent to ``%H:%M:%S''. | |
139 | .TP | |
00b602b8 KB |
140 | .B %U |
141 | is replaced by the week number of the year (Sunday as the first day of | |
142 | the week) as a decimal number (00-53). | |
143 | .TP | |
144 | .B %W | |
145 | is replaced by the week number of the year (Monday as the first day of | |
146 | the week) as a decimal number (00-53). | |
147 | .TP | |
148 | .B %w | |
149 | is replaced by the weekday (Sunday as the first day of the week) | |
150 | as a decimal number (0-6). | |
151 | .TP | |
00b602b8 | 152 | .B %x |
5a2e4b32 | 153 | is equivalent to ``%m/%d/%y %H:%M:%S''. |
00b602b8 KB |
154 | .TP |
155 | .B %Y | |
156 | is replaced by the year with century as a decimal number. | |
157 | .TP | |
158 | .B %y | |
159 | is replaced by the year without century as a decimal number (00-99). | |
160 | .TP | |
161 | .B %Z | |
162 | is replaced by the time zone name. | |
163 | .TP | |
164 | .B %% | |
165 | is replaced by ``%''. | |
166 | .SH "SEE ALSO" | |
14fd63d8 | 167 | date(1), ctime(3), printf(1), printf(3) |