liveBook · Manning

Strftime

As explained in Modern C

strftime is a C standard library function that formats a broken-down time into a character string according to date-and-time conversion specifications.

strftime formats a broken-down time as text by combining a destination buffer, a format string, and a struct tm value. It resembles printf, but uses date-and-time conversion specifications beginning with %. TAKEAWAY: choose the format string to control the textual representation. section 8.5

The interface

size_t strftime(char s[static 1], size_t max, const char format[static 1], struct tm const tm[static 1]); Here, s is the character array to fill, max limits the available size, format describes the representation, and tm supplies the broken-down time. For example, %Y selects the year, %m the month, and %d the day of the month; combining such specifications composes a date representation. section 8.5

How Modern C covers it

How deep it goes
Defines the interface and conversion families, while deferring pointer rationale and locale access.
Examples
Uses the function declaration and a reference table of date, time, locale, and ISO 8601 conversion specifications.
What it assumes
Assumes familiarity with struct tm and C arrays, while deferring the pointer explanation for array parameters.
What you can do after
Apply strftime to compose date-and-time strings from struct tm values and conversion specifications.
How it connects
Connects broken-down time with struct tm, time_t, mktime, locale, and ISO 8601.

Also explained in

Compare how 2 books explain strftime →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Modern C. The section links point to the parts of the book it draws on.