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