Localtime Function
Syntax:
struct tm *localtime(const time_t *time);
Example:
#include <time.h>
#include <stdio.h>
/* Print local and UTC time. */
int main()
{
struct tm *local_time;
time_t t;
t = time(NULL);
local_time = localtime(&t);
printf("Local time and date: %s\n", asctime(local_time));
local_time = gmtime(&t);
printf("UTC time and date: %s\n", asctime(local_time));
return 0;
}
Back