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