C program to get system Uptime and print hrs, mins, day etc..
/*
localtime example */
#include
<stdio.h>
#include
<time.h>
int
main ()
{
time_t rawtime;
struct tm * timeinfo;
int month_correction = 1;
int year_correction = 1900;
time ( &rawtime );
timeinfo = localtime ( &rawtime );
printf ( "\n Current local time and
date: %s \n", asctime (timeinfo) );
printf("\n Hour: %d",
timeinfo->tm_hour);
printf("\n Min: %d",
timeinfo->tm_min);
printf("\n Sec: %d",
timeinfo->tm_sec);
printf("\n Day: %d",
timeinfo->tm_mday);
printf("\n Month:
%ld",timeinfo->tm_mon + month_correction );
printf("\n year: %d",
timeinfo->tm_year + year_correction);
printf("\n");
return 0;
}
Output: