localtime

Converts a time into a structure using the local timezone information.

struct tm localtime (time_t * timer);

Required Header
<time.h>

Return Value

This function returns a pointer to a structure representing the time.

Parameters

timer

  The time to convert

Remarks

The localtime function converts the timer value into a structure which contains the various parts that make up the time as follows:

struct tm {
    int  tm_sec;    /* seconds after the minute [0-60] */
    int  tm_min;    /* minutes after the hour [0-59] */
    int  tm_hour;   /* hours since midnight [0-23] */
    int  tm_mday;   /* day of the month [1-31] */
    int  tm_mon;    /* months since January [0-11] */
    int  tm_year;   /* years since 1900 */
    int  tm_wday;   /* days since Sunday [0-6] */
    int  tm_yday;   /* days since January 1 [0-365] */
    int  tm_isdst;  /* Daylight Savings Time flag */
    long tm_gmtoff; /* offset from CUT in seconds */
    char *tm_zone;  /* timezone abbreviation */
};

localtime and gmtime use the same internal static buffer, and the result should be copied before making calls to one or the other function. The static buffer is thread-safe however.

Time

See Also    asctime, ctime, gmtime, mktime, time