1.\" Copyright (c) 1989, 1991, 1993 2.\" The Regents of the University of California. All rights reserved. 3.\" 4.\" This code is derived from software contributed to Berkeley by 5.\" the American National Standards Committee X3, on Information 6.\" Processing Systems. 7.\" 8.\" Redistribution and use in source and binary forms, with or without 9.\" modification, are permitted provided that the following conditions 10.\" are met: 11.\" 1. Redistributions of source code must retain the above copyright 12.\" notice, this list of conditions and the following disclaimer. 13.\" 2. Redistributions in binary form must reproduce the above copyright 14.\" notice, this list of conditions and the following disclaimer in the 15.\" documentation and/or other materials provided with the distribution. 16.\" 3. All advertising materials mentioning features or use of this software 17.\" must display the following acknowledgement: 18.\" This product includes software developed by the University of 19.\" California, Berkeley and its contributors. 20.\" 4. Neither the name of the University nor the names of its contributors 21.\" may be used to endorse or promote products derived from this software 22.\" without specific prior written permission. 23.\" 24.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 25.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 26.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 27.\" ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 28.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 29.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 30.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 31.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 32.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 33.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 34.\" SUCH DAMAGE. 35.\" 36.\" @(#)strftime.3 8.1 (Berkeley) 6/4/93 37.\" 38.Dd June 4, 1993 39.Dt STRFTIME 3 40.Os 41.Sh NAME 42.Nm strftime 43.Nd format date and time 44.Sh SYNOPSIS 45.Fd #include <sys/types.h> 46.Fd #include <time.h> 47.Fd #include <string.h> 48.Ft size_t 49.Fn strftime "char *buf" "size_t maxsize" "const char *format" "const struct tm *timeptr" 50.Sh DESCRIPTION 51The 52.Fn strftime 53function formats the information from 54.Fa timeptr 55into the buffer 56.Fa buf 57according to the string pointed to by 58.Fa format . 59.Pp 60The 61.Fa format 62string consists of zero or more conversion specifications and 63ordinary characters. 64All ordinary characters are copied directly into the buffer. 65A conversion specification consists of a percent sign 66.Dq Ql % 67and one other character. 68.Pp 69No more than 70.Fa maxsize 71characters will be placed into the array. 72If the total number of resulting characters, including the terminating 73null character, is not more than 74.Fa maxsize , 75.Fn strftime 76returns the number of characters in the array, not counting the 77terminating null. 78Otherwise, zero is returned. 79.Pp 80Each conversion specification is replaced by the characters as 81follows which are then copied into the buffer. 82.Bl -tag -width "xxxx" 83.It Cm \&%A 84is replaced by the full weekday name. 85.It Cm %a 86is replaced by the abbreviated weekday name, where the abbreviation 87is the first three characters. 88.It Cm \&%B 89is replaced by the full month name. 90.It Cm %b or %h 91is replaced by the abbreviated month name, where the abbreviation is 92the first three characters. 93.It Cm \&%C 94is equivalent to 95.Dq Li %a %b %e %H:%M:%S %Y 96(the format produced by 97.Xr asctime 3 . 98.It Cm %c 99is equivalent to 100.Dq Li %m/%d/%y . 101.It Cm \&%D 102is replaced by the date in the format 103.Dq Ql mm/dd/yy . 104.It Cm %d 105is replaced by the day of the month as a decimal number (01-31). 106.It Cm %e 107is replaced by the day of month as a decimal number (1-31); single 108digits are preceded by a blank. 109.It Cm \&%H 110is replaced by the hour (24-hour clock) as a decimal number (00-23). 111.It Cm \&%I 112is replaced by the hour (12-hour clock) as a decimal number (01-12). 113.It Cm %j 114is replaced by the day of the year as a decimal number (001-366). 115.It Cm %k 116is replaced by the hour (24-hour clock) as a decimal number (0-23); 117single digits are preceded by a blank. 118.It Cm %l 119is replaced by the hour (12-hour clock) as a decimal number (1-12); 120single digits are preceded by a blank. 121.It Cm \&%M 122is replaced by the minute as a decimal number (00-59). 123.It Cm %m 124is replaced by the month as a decimal number (01-12). 125.It Cm %n 126is replaced by a newline. 127.It Cm %p 128is replaced by either 129.Dq Tn AM 130or 131.Dq Tn PM 132as appropriate. 133.It Cm \&%R 134is equivalent to 135.Dq Li %H:%M 136.It Cm %r 137is equivalent to 138.Dq Li %I:%M:%S %p . 139.It Cm %t 140is replaced by a tab. 141.It Cm \&%S 142is replaced by the second as a decimal number (00-60). 143.It Cm %s 144is replaced by the number of seconds since the Epoch, UCT (see 145.Xr mktime 3 ) . 146.It Cm \&%T No or Cm \&%X 147is equivalent to 148.Dq Li %H:%M:%S . 149.It Cm \&%U 150is replaced by the week number of the year (Sunday as the first day of 151the week) as a decimal number (00-53). 152.It Cm \&%W 153is replaced by the week number of the year (Monday as the first day of 154the week) as a decimal number (00-53). 155.It Cm %w 156is replaced by the weekday (Sunday as the first day of the week) 157as a decimal number (0-6). 158.It Cm %x 159is equivalent to 160.Dq Li %m/%d/%y %H:%M:%S . 161.It Cm \&%Y 162is replaced by the year with century as a decimal number. 163.It Cm %y 164is replaced by the year without century as a decimal number (00-99). 165.It Cm \&%Z 166is replaced by the time zone name. 167.It Cm %% 168is replaced by 169.Ql % . 170.El 171.Sh SEE ALSO 172.Xr date 1 , 173.Xr ctime 3 , 174.Xr printf 1 , 175.Xr printf 3 176.Sh STANDARDS 177The 178.Fn strftime 179function 180conforms to 181.St -ansiC . 182The 183.Ql %s 184conversion specification is an extension. 185.Sh BUGS 186There is no conversion specification for the phase of the moon. 187