localtime
Localtime is a function in the C standard library that converts a time value to a broken-down calendar time in the system’s local time zone. The input is a pointer to time_t, and the function returns a pointer to a statically allocated struct tm containing fields such as tm_year, tm_mon, tm_mday, tm_hour, tm_min, tm_sec, tm_wday, tm_yday, and tm_isdst. The resulting values reflect the local offset from UTC and any daylight saving time (DST) adjustments as determined by the system’s time zone data.
The function uses the system’s time zone settings, which may be influenced by environment configuration (for
Because localtime returns a pointer to a static internal buffer, its contents can be overwritten by subsequent
Related functions include gmtime, which converts time_t to Coordinated Universal Time (UTC) without regard to local