1.TH STRFTIME 3 scc\-VERSION2.SH NAME3strftime - format a broken-down time value into a string4.SH SYNOPSIS5#include <time.h>67.nf8size_t strftime(char * restrict s,9 size_t maxsize,10 const char * restrict format,11 const struct tm * restrict timeptr);12.fi13.SH DESCRIPTION14The15.BR strftime ()16function writes characters into the array pointed to by17.I s18under control of the string pointed to by19.IR format .2021The22.I format23string is a multibyte character sequence that begins and ends24in its initial shift state.25It consists of zero or more conversion specifiers26interspersed with ordinary characters.27Each conversion specifier begins with a28.B %29character, optionally followed by an30.B E31or32.B O33modifier, and ends with a character that determines what is substituted.34Ordinary characters, including the terminating null byte,35are copied to the output without modification.36No more than37.I maxsize38characters are placed into the array.3940The following conversion specifiers are recognized:41.TP42.B %a43The abbreviated weekday name for the current locale.44.TP45.B %A46The full weekday name for the current locale.47.TP48.B %b49The abbreviated month name for the current locale.50.TP51.B %B52The full month name for the current locale.53.TP54.B %c55The preferred date and time representation for the current locale.56.TP57.B %C58The year divided by 100, truncated to an integer (the century).59.TP60.B %d61The day of the month as a two-digit decimal number (01 to 31).62.TP63.B %D64Equivalent to "%m/%d/%y".65.TP66.B %e67The day of the month as a decimal number; single digits are padded with a space.68.TP69.B %F70Equivalent to "%Y-%m-%d" (ISO 8601 date format).71.TP72.B %G73The ISO 8601 week-based year, including the century.74(Derived from75.BR tm_year ,76.BR tm_yday ,77and78.BR tm_wday .)79.TP80.B %g81Like82.B %G83but without the century (two-digit year, 00 to 99).84(Derived from85.BR tm_year ,86.BR tm_yday ,87and88.BR tm_wday .)89.TP90.B %h91Equivalent to92.BR %b .93(Derived from94.BR tm_mon .)95.TP96.B %H97The hour on a 24-hour clock as a two-digit decimal number (00 to 23).98(Derived from99.BR tm_hour .)100.TP101.B %I102The hour on a 12-hour clock as a two-digit decimal number (01 to 12).103(Derived from104.BR tm_hour .)105.TP106.B %j107The day of the year as a three-digit decimal number (001 to 366).108(Derived from109.BR tm_yday .)110.TP111.B %m112The month as a two-digit decimal number (01 to 12).113(Derived from114.BR tm_mon .)115.TP116.B %M117The minute as a two-digit decimal number (00 to 59).118.TP119.B %n120A newline character.121.TP122.B %p123Either "AM" or "PM" according to the time of day.124(Derived from125.BR tm_hour .)126.TP127.B %r128The locale's 12-hour clock time.129.TP130.B %R131The time in 24-hour notation (%H:%M).132.TP133.B %S134The second as a two-digit decimal number (00 to 60).135(Derived from136.BR tm_sec .)137.TP138.B %t139A tab character.140.TP141.B %T142The time in 24-hour notation (%H:%M:%S).143.TP144.B %u145The weekday as a decimal number per ISO 8601 (1 to 7, Monday = 1).146(Derived from147.BR tm_wday .)148.TP149.B %U150The week number of the year as a two-digit decimal (00 to 53),151counting from the first Sunday as day 1 of week 1.152(Derived from153.BR tm_year ,154.BR tm_wday ,155.BR tm_yday .)156.TP157.B %V158The ISO 8601 week number of the year (01 to 53),159where week 1 is the first week containing at least four days of the new year.160.TP161.B %w162The weekday as a decimal number (0 to 6, Sunday = 0).163.TP164.B %W165The week number of the year as a two-digit decimal (00 to 53),166counting from the first Monday as day 1 of week 1.167(Derived from168.B tm_yday169and170.BR tm_wday .)171.TP172.B %x173The preferred date representation for the current locale, without the time.174.TP175.B %X176The preferred time representation for the current locale, without the date.177.TP178.B %y179The year without the century (00 to 99).180.TP181.B %Y182The year including the century.183.TP184.B %z185The UTC offset as +hhmm or -hhmm (ISO 8601 format).186.TP187.B %Z188The timezone name or abbreviation.189.TP190.B %%191A literal percent sign.192.P193The194.B E195and196.B O197modifier characters may precede certain conversion specifiers198to request an alternative locale-specific representation.199When no alternative exists, the modifier is ignored.200201The C standard recognizes the following modified specifiers:202.BR %Ec ,203.BR %EC ,204.BR %Ex ,205.BR %EX ,206.BR %Ey ,207.BR %EY ,208.BR %Od ,209.BR %Oe ,210.BR %OH ,211.BR %OI ,212.BR %Om ,213.BR %OM ,214.BR %OS ,215.BR %Ou ,216.BR %OU ,217.BR %OV ,218.BR %Ow ,219.BR %OW ,220.BR %Oy .221The222.B O223modifier requests locale alternative numeric symbols;224the225.B E226modifier requests a locale-dependent alternative representation.227228In the "C" locale, both modifiers are ignored and229the following substitutions apply:230.TP231.B %a232the first three characters of %A233.TP234.B %A235one of Sunday, Monday, ..., Saturday236.TP237.B %b238the first three characters of %B239.TP240.B %B241one of January, February, ..., December242.TP243.B %c244equivalent to %a %b %e %T %Y245.TP246.B %p247one of AM or PM248.TP249.B %r250equivalent to %I:%M:%S %p251.TP252.B %x253equivalent to %m/%d/%y254.TP255.B %X256equivalent to %T257.TP258.B %Z259the timezone name or abbreviation260.SH RETURN VALUE261When the formatted result, including the terminating null byte,262fits within263.I maxsize264characters,265.B strftime266returns the number of characters written, excluding the null byte.267If the result does not fit, zero is returned and the contents268of the array are unspecified.269.SH NOTES270ISO 8601 week-based years begin on Monday, with week 1 defined as271the week containing January 4th (equivalently, the first week with272at least four days in the new year, or the week containing the273first Thursday of the year).274The specifiers275.BR %g ,276.BR %G ,277and278.B %V279follow this convention. For example, Saturday January 2nd 1999280falls in week 53 of 1998 (%G = 1998, %V = 53);281Tuesday December 30th 1997 falls in week 1 of 1998 (%G = 1998, %V = 01).282.SH STANDARDS283ISO/IEC 9899:1999 Section 7.23.3.5 Paragraph 1,2,3,4,5,6,7284.SH SEE ALSO285.BR time.h (3)