struct tm * localtime (const time_t * timer);
Convert time_t to tm as local time
Uses the value pointed by timer to fill a tm structure with the values that represent the corresponding time, expressed for the local timezone.
- Pointer to an object of type time_t that contains a time value.
time_t is an alias of a fundamental arithmetic type capable of representing times as returned by function time.
A pointer to a tm structure with its members filled with the values that correspond to the local time representation of timer.
The returned value points to an internal object whose validity or value may be altered by any subsequent call to gmtime or localtime.
/* localtime example */
#include <stdio.h> /* puts, printf */
#include <time.h> /* time_t, struct tm, time, localtime */
int main ()
struct tm * timeinfo;
timeinfo = localtime (&rawtime);
printf ("Current local time and date: %s", asctime(timeinfo));
Current local time and date: Wed Feb 13 17:17:11 2013
The function accesses the object pointed by timer.
The function also accesses and modifies a shared internal object, which may introduce data races on concurrent calls to gmtime and localtime. Some libraries provide an alternative function that avoids this data race: localtime_r (non-portable).
No-throw guarantee: this function never throws exceptions.
- Convert tm structure to string (function)
- Convert time_t value to string (function)
- Convert time_t to tm as UTC time (function)
- Convert tm structure to time_t (function)
- Get current time (function)