C examples for time.h:localtime
function
<ctime> <time.h>
Convert time_t to tm as local time
struct tm * localtime (const time_t * timer);
Parameter | Description |
---|---|
timer | a time value in type time_t. |
tm structure in the local time representation of timer.
#pragma warning(disable:4996)//w w w . j a va 2s. c o m #define _CRT_SECURE_NO_WARNINGS #include <stdio.h> #include <time.h> int main() { time_t rawtime; struct tm * timeinfo; time(&rawtime); timeinfo = localtime(&rawtime); printf("Current local time and date: %s", asctime(timeinfo)); return 0; }