'\" t .TH "STRFTIME" "3" "01/19/2023" "newlib" "Time Functions (time.h)" .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .nh .\" .ad l .\" .SH "NAME" .\" strftime, strftime_l \- convert date and time to a formatted string .\" .SH "SYNOPSIS" .\" .sp .\" .ft B .\" .nf .\" #include .\" .fi .\" .ft .\" .HP \w'size_t\ strftime('u .\" .BI "size_t strftime(char\ *restrict\ " "s" ", size_t\ " "maxsize" ", const\ char\ *restrict\ " "format" ", const\ struct\ tm\ *restrict\ " "timp" ");" .\" .HP \w'size_t\ strftime_l('u .\" .BI "size_t strftime_l(char\ *restrict\ " "s" ", size_t\ " "maxsize" ", const\ char\ *restrict\ " "format" ", const\ struct\ tm\ *restrict\ " "timp" ", locale_t\ " "locale" ");" .SH "DESCRIPTION" .PP .\" strftime .\" converts a .\" struct tm .\" representation of the time (at .\" \fItimp\fR) into a null\-terminated string, starting at .\" \fIs\fR .\" and occupying no more than .\" \fImaxsize\fR .\" characters\&. .PP .\" strftime_l .\" is like .\" strftime .\" but creates a string in a format as expected in locale .\" \fIlocale\fR\&. If .\" \fIlocale\fR .\" is LC_GLOBAL_LOCALE or not a valid locale object, the behaviour is undefined\&. .PP .\" You control the format of the output using the string at .\" \fIformat\fR\&. .\" *\fIformat\fR .\" can contain two kinds of specifications: text to be copied literally into the formatted string, and time conversion specifications\&. Time conversion specifications are two\- and three\-character sequences beginning with `%\*(Aq (use `%%\*(Aq to include a percent sign in the output)\&. Each defined conversion specification selects only the specified field(s) of calendar time data from .\" *\fItimp\fR, and converts it to a string in one of the following ways: .PP .TS tab(:); l lx. T{ %a T}:T{ The abbreviated weekday name according to the current locale\&. [tm_wday] T} \& T{ %A T}:T{ The full weekday name according to the current locale\&. In the default "C" locale, one of `Sunday\*(Aq, `Monday\*(Aq, `Tuesday\*(Aq, `Wednesday\*(Aq, `Thursday\*(Aq, `Friday\*(Aq, `Saturday\*(Aq\&. [tm_wday] T} \& T{ %b T}:T{ The abbreviated month name according to the current locale\&. [tm_mon] T} \& T{ %B T}:T{ The full month name according to the current locale\&. In the default "C" locale, one of `January\*(Aq, `February\*(Aq, `March\*(Aq, `April\*(Aq, `May\*(Aq, `June\*(Aq, `July\*(Aq, `August\*(Aq, `September\*(Aq, `October\*(Aq, `November\*(Aq, `December\*(Aq\&. [tm_mon] T} \& T{ %c T}:T{ The preferred date and time representation for the current locale\&. [tm_sec, tm_min, tm_hour, tm_mday, tm_mon, tm_year, tm_wday] T} \& T{ %C T}:T{ The century, that is, the year divided by 100 then truncated\&. For 4\-digit years, the result is zero\-padded and exactly two characters; but for other years, there may a negative sign or more digits\&. In this way, `%C%y\*(Aq is equivalent to `%Y\*(Aq\&. [tm_year] T} \& T{ %d T}:T{ The day of the month, formatted with two digits (from `01\*(Aq to `31\*(Aq)\&. [tm_mday] T} \& T{ %D T}:T{ A string representing the date, in the form `"%m/%d/%y"\*(Aq\&. [tm_mday, tm_mon, tm_year] T} \& T{ %e T}:T{ The day of the month, formatted with leading space if single digit (from `1\*(Aq to `31\*(Aq)\&. [tm_mday] T} \& T{ %Ex T}:T{ In some locales, the E modifier selects alternative representations of certain modifiers x\&. In newlib, it is ignored, and treated as %x\&. T} \& T{ %F T}:T{ A string representing the ISO 8601:2000 date format, in the form `"%Y\-%m\-%d"\*(Aq\&. [tm_mday, tm_mon, tm_year] T} \& T{ %g T}:T{ The last two digits of the week\-based year, see specifier %G (from `00\*(Aq to `99\*(Aq)\&. [tm_year, tm_wday, tm_yday] T} \& T{ %G T}:T{ The week\-based year\&. In the ISO 8601:2000 calendar, week 1 of the year includes January 4th, and begin on Mondays\&. Therefore, if January 1st, 2nd, or 3rd falls on a Sunday, that day and earlier belong to the last week of the previous year; and if December 29th, 30th, or 31st falls on Monday, that day and later belong to week 1 of the next year\&. For consistency with %Y, it always has at least four characters\&. Example: "%G" for Saturday 2nd January 1999 gives "1998", and for Tuesday 30th December 1997 gives "1998"\&. [tm_year, tm_wday, tm_yday] T} \& T{ %h T}:T{ Synonym for "%b"\&. [tm_mon] T} \& T{ %H T}:T{ The hour (on a 24\-hour clock), formatted with two digits (from `00\*(Aq to `23\*(Aq)\&. [tm_hour] T} \& T{ %I T}:T{ The hour (on a 12\-hour clock), formatted with two digits (from `01\*(Aq to `12\*(Aq)\&. [tm_hour] T} \& T{ %j T}:T{ The count of days in the year, formatted with three digits (from `001\*(Aq to `366\*(Aq)\&. [tm_yday] T} \& T{ %k T}:T{ The hour (on a 24\-hour clock), formatted with leading space if single digit (from `0\*(Aq to `23\*(Aq)\&. Non\-POSIX extension (c\&.p\&. %I)\&. [tm_hour] T} \& T{ %l T}:T{ The hour (on a 12\-hour clock), formatted with leading space if single digit (from `1\*(Aq to `12\*(Aq)\&. Non\-POSIX extension (c\&.p\&. %H)\&. [tm_hour] T} \& T{ %m T}:T{ The month number, formatted with two digits (from `01\*(Aq to `12\*(Aq)\&. [tm_mon] T} \& T{ %M T}:T{ The minute, formatted with two digits (from `00\*(Aq to `59\*(Aq)\&. [tm_min] T} \& T{ %n T}:T{ A newline character (`\en\*(Aq)\&. T} \& T{ %Ox T}:T{ In some locales, the O modifier selects alternative digit characters for certain modifiers x\&. In newlib, it is ignored, and treated as %x\&. T} \& T{ %p T}:T{ Either `AM\*(Aq or `PM\*(Aq as appropriate, or the corresponding strings for the current locale\&. [tm_hour] T} \& T{ %P T}:T{ Same as \*(Aq%p\*(Aq, but in lowercase\&. This is a GNU extension\&. [tm_hour] T} \& T{ %q T}:T{ Quarter of the year (from `1\*(Aq to `4\*(Aq), with January starting the first quarter\&. This is a GNU extension\&. [tm_mon] T} \& T{ %r T}:T{ Replaced by the time in a\&.m\&. and p\&.m\&. notation\&. In the "C" locale this is equivalent to "%I:%M:%S %p"\&. In locales which don\*(Aqt define a\&.m\&./p\&.m\&. notations, the result is an empty string\&. [tm_sec, tm_min, tm_hour] T} \& T{ %R T}:T{ The 24\-hour time, to the minute\&. Equivalent to "%H:%M"\&. [tm_min, tm_hour] T} \& T{ %s T}:T{ The time elapsed, in seconds, since the start of the Unix epoch at 1970\-01\-01 00:00:00 UTC\&. T} \& T{ %S T}:T{ The second, formatted with two digits (from `00\*(Aq to `60\*(Aq)\&. The value 60 accounts for the occasional leap second\&. [tm_sec] T} \& T{ %t T}:T{ A tab character (`\et\*(Aq)\&. T} \& T{ %T T}:T{ The 24\-hour time, to the second\&. Equivalent to "%H:%M:%S"\&. [tm_sec, tm_min, tm_hour] T} \& T{ %u T}:T{ The weekday as a number, 1\-based from Monday (from `1\*(Aq to `7\*(Aq)\&. [tm_wday] T} \& T{ %U T}:T{ The week number, where weeks start on Sunday, week 1 contains the first Sunday in a year, and earlier days are in week 0\&. Formatted with two digits (from `00\*(Aq to `53\*(Aq)\&. See also %W\&. [tm_wday, tm_yday] T} \& T{ %V T}:T{ The week number, where weeks start on Monday, week 1 contains January 4th, and earlier days are in the previous year\&. Formatted with two digits (from `01\*(Aq to `53\*(Aq)\&. See also %G\&. [tm_year, tm_wday, tm_yday] T} \& T{ %v T}:T{ A string representing the BSD/OSX/Ruby VMS/Oracle date format, in the form "%e\-%b\-%Y"\&. Non\-POSIX extension\&. [tm_mday, tm_mon, tm_year] T} \& T{ %w T}:T{ The weekday as a number, 0\-based from Sunday (from `0\*(Aq to `6\*(Aq)\&. [tm_wday] T} \& T{ %W T}:T{ The week number, where weeks start on Monday, week 1 contains the first Monday in a year, and earlier days are in week 0\&. Formatted with two digits (from `00\*(Aq to `53\*(Aq)\&. [tm_wday, tm_yday] T} \& T{ %x T}:T{ Replaced by the preferred date representation in the current locale\&. In the "C" locale this is equivalent to "%m/%d/%y"\&. [tm_mon, tm_mday, tm_year] T} \& T{ %X T}:T{ Replaced by the preferred time representation in the current locale\&. In the "C" locale this is equivalent to "%H:%M:%S"\&. [tm_sec, tm_min, tm_hour] T} \& T{ %y T}:T{ The last two digits of the year (from `00\*(Aq to `99\*(Aq)\&. [tm_year] (Implementation interpretation: always positive, even for negative years\&.) T} \& T{ %Y T}:T{ The full year, equivalent to %C%y\&. It will always have at least four characters, but may have more\&. The year is accurate even when tm_year added to the offset of 1900 overflows an int\&. [tm_year] T} \& T{ %z T}:T{ The offset from UTC\&. The format consists of a sign (negative is west of Greewich), two characters for hour, then two characters for minutes (\-hhmm or +hhmm)\&. If tm_isdst is negative, the offset is unknown and no output is generated; if it is zero, the offset is the standard offset for the current time zone; and if it is positive, the offset is the daylight savings offset for the current timezone\&. The offset is determined from the TZ environment variable, as if by calling tzset()\&. [tm_isdst] T} \& T{ %Z T}:T{ The current time zone abbreviation\&. If tm_isdst is negative, no output is generated\&. Otherwise, the time zone abbreviation is based on the TZ environment variable, as if by calling tzset()\&. [tm_isdst] T} \& T{ %% T}:T{ A single character, `%\*(Aq\&. T} \& .TE