#include<time.h>
#include<stdio.h>
#include<conio.h>
void main()
{
long time1;
struct tm strtm;
clrscr();
time(&time1);
strtm = *localtime(&time1);
printf(" \n time %ld",time1);
printf(" \n time.tm_sec %d ",strtm.tm_sec);
printf(" \n time.tm_min %d",strtm.tm_min);
printf(" \n time.tm_hour %d",strtm.tm_hour);
printf(" \n time.tm_mday %d",strtm.tm_mday);
printf(" \n time.tm_mon %d",strtm.tm_mon);
printf(" \n time.tm_year %d", strtm.tm_year);
printf(" \n time.tm_wday %d",strtm.tm_wday);
getch();
}
output:
time 1157402802
time.tm_sec 42
time.tm_min 46
time.tm_hour 16
time.tm_mday 4
time.tm_mon 8
time.tm_year 106
time.tm_wday 1
This code will get the current system local time and print the details..as shown above
so for ur verification..
compare the details accordingly.. and do the rest.
struct tm... variables..
int tm_sec; seconds after the minute
int tm_min; minutes after the hour
int tm_hour; hours since midnight
int tm_mday; day of the month
int tm_mon; months since January
int tm_year; years since 1900
int tm_wday; days since Sunday
int tm_yday; days since January 1
int tm_isdst; Daylight Saving Time flag