1*48351Scael.\" Copyright (c) 1989, 1991 The Regents of the University of California. 237122Sbostic.\" All rights reserved. 337122Sbostic.\" 443567Strent.\" %sccs.include.redist.man% 537122Sbostic.\" 6*48351Scael.\" @(#)strftime.3 5.11 (Berkeley) 04/19/91 737122Sbostic.\" 8*48351Scael.Dd 9*48351Scael.Dt STRFTIME 3 10*48351Scael.Os 11*48351Scael.Sh NAME 12*48351Scael.Nm strftime 13*48351Scael.Nd format date and time 14*48351Scael.Sh SYNOPSIS 15*48351Scael.Fd #include <sys/types.h> 16*48351Scael.Fd #include <time.h> 17*48351Scael.Fd #include <string.h> 18*48351Scael.Ft size_t 19*48351Scael.Fn strftime "char *buf" "size_t maxsize" "const char *format" "const struct tm *timeptr" 20*48351Scael.Sh DESCRIPTION 2137122SbosticThe 22*48351Scael.Fn strftime 2337122Sbosticfunction formats the information from 24*48351Scael.Fa timeptr 2537122Sbosticinto the buffer 26*48351Scael.Fa buf 2737122Sbosticaccording to the string pointed to by 28*48351Scael.Fa format . 29*48351Scael.Pp 3037122SbosticThe 31*48351Scael.Fa format 3237122Sbosticstring consists of zero or more conversion specifications and 3337122Sbosticordinary characters. 3437122SbosticAll ordinary characters are copied directly into the buffer. 35*48351ScaelA conversion specification consists of a percent sign 36*48351Scael.Dq Ql % 3737122Sbosticand one other character. 38*48351Scael.Pp 3937122SbosticNo more than 40*48351Scael.Fa maxsize 4137122Sbosticcharacters will be placed into the array. 4237122SbosticIf the total number of resulting characters, including the terminating 4337122Sbosticnull character, is not more than 44*48351Scael.Fa maxsize , 45*48351Scael.Fn strftime 4637122Sbosticreturns the number of characters in the array, not counting the 4737122Sbosticterminating null. 4837122SbosticOtherwise, zero is returned. 49*48351Scael.Pp 5037122SbosticEach conversion specification is replaced by the characters as 5137122Sbosticfollows which are then copied into the buffer. 52*48351Scael.Bl -tag -width "xxxx" 53*48351Scael.It Cm \&%A 5437122Sbosticis replaced by the full weekday name. 55*48351Scael.It Cm %a 5637122Sbosticis replaced by the abbreviated weekday name, where the abbreviation 5737122Sbosticis the first three characters. 58*48351Scael.It Cm \&%B 5937122Sbosticis replaced by the full month name. 60*48351Scael.It Cm %b or %h 6137122Sbosticis replaced by the abbreviated month name, where the abbreviation is 6237122Sbosticthe first three characters. 63*48351Scael.It Cm \&%C 64*48351Scaelis equivalent to 65*48351Scael.Dq Li %a %b %e %H:%M:%S %Y 66*48351Scael(the format produced by 67*48351Scael.Xr asctime 3 . 68*48351Scael.It Cm %c 69*48351Scaelis equivalent to 70*48351Scael.Dq Li %m/%d/%y . 71*48351Scael.It Cm \&%D 72*48351Scaelis replaced by the date in the format 73*48351Scael.Dq Ql mm/dd/yy . 74*48351Scael.It Cm %d 7537122Sbosticis replaced by the day of the month as a decimal number (01-31). 76*48351Scael.It Cm %e 7737346Sbosticis replaced by the day of month as a decimal number (1-31); single 7837346Sbosticdigits are preceded by a blank. 79*48351Scael.It Cm \&%H 8037122Sbosticis replaced by the hour (24-hour clock) as a decimal number (00-23). 81*48351Scael.It Cm \&%I 8237122Sbosticis replaced by the hour (12-hour clock) as a decimal number (01-12). 83*48351Scael.It Cm %j 8437122Sbosticis replaced by the day of the year as a decimal number (001-366). 85*48351Scael.It Cm %k 8637346Sbosticis replaced by the hour (24-hour clock) as a decimal number (0-23); 8737346Sbosticsingle digits are preceded by a blank. 88*48351Scael.It Cm %l 8946041Sbosticis replaced by the hour (12-hour clock) as a decimal number (1-12); 9037346Sbosticsingle digits are preceded by a blank. 91*48351Scael.It Cm \&%M 9237138Sbosticis replaced by the minute as a decimal number (00-59). 93*48351Scael.It Cm %m 9437122Sbosticis replaced by the month as a decimal number (01-12). 95*48351Scael.It Cm %n 9637138Sbosticis replaced by a newline. 97*48351Scael.It Cm %p 98*48351Scaelis replaced by either 99*48351Scael.Dq Tn AM 100*48351Scaelor 101*48351Scael.Dq Tn PM 102*48351Scaelas appropriate. 103*48351Scael.It Cm \&%R 104*48351Scaelis equivalent to 105*48351Scael.Dq Li %H:%M 106*48351Scael.It Cm %r 107*48351Scaelis equivalent to 108*48351Scael.Dq Li %I:%M:%S %p . 109*48351Scael.It Cm %t 11037138Sbosticis replaced by a tab. 111*48351Scael.It Cm \&%S 11237122Sbosticis replaced by the second as a decimal number (00-60). 113*48351Scael.It Cm %s 11445668Sbosticis replaced by the number of seconds since the Epoch, UCT (see 115*48351Scael.Xr mktime 3 ) . 116*48351Scael.It Cm \&%T No or Cm \&%X 117*48351Scaelis equivalent to 118*48351Scael.Dq Li %H:%M:%S . 119*48351Scael.It Cm \&%U 12037122Sbosticis replaced by the week number of the year (Sunday as the first day of 12137122Sbosticthe week) as a decimal number (00-53). 122*48351Scael.It Cm \&%W 12337122Sbosticis replaced by the week number of the year (Monday as the first day of 12437122Sbosticthe week) as a decimal number (00-53). 125*48351Scael.It Cm %w 12637122Sbosticis replaced by the weekday (Sunday as the first day of the week) 12737122Sbosticas a decimal number (0-6). 128*48351Scael.It Cm %x 129*48351Scaelis equivalent to 130*48351Scael.Dq Li %m/%d/%y %H:%M:%S . 131*48351Scael.It Cm \&%Y 13237122Sbosticis replaced by the year with century as a decimal number. 133*48351Scael.It Cm %y 13437122Sbosticis replaced by the year without century as a decimal number (00-99). 135*48351Scael.It Cm \&%Z 13637122Sbosticis replaced by the time zone name. 137*48351Scael.It Cm %% 138*48351Scaelis replaced by 139*48351Scael.Ql % . 140*48351Scael.El 141*48351Scael.Sh SEE ALSO 142*48351Scael.Xr date 1 , 143*48351Scael.Xr ctime 3 , 144*48351Scael.Xr printf 1 , 145*48351Scael.Xr printf 3 146*48351Scael.Sh STANDARDS 147*48351ScaelThe 148*48351Scael.Fn strftime 149*48351Scaelfunction 150*48351Scaelconforms to 151*48351Scael.St -ansiC . 152*48351ScaelThe 153*48351Scael.Ql %s 154*48351Scaelconversion specification is an extension. 155*48351Scael.Sh BUGS 15645695SbosticThere is no conversion specification for the phase of the moon. 157