Home >>C Time Library Function >C localtime() function
C localtime() function is used to convert the given time since epoch to calendar time which is expressed as local time. It uses the time pointed by timer to fill a tm structure with the values that represent the corresponding local time. This function is defined in <time.h> header file.
Syntax:struct tm *localtime(const time_t *timer)
timer− It is the pointer to a time_t value representing a calendar time.
Here is an example of localtime() function:
#include <stdio.h>
#include <time.h>
int main ()
{
time_t rawtime;
struct tm *info;
time( &rawtime );
info = localtime( &rawtime );
printf("Current local time and date: %s", asctime(info));
return(0);
}