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