Time structure
struct tm
{
int tm_sec;
int tm_min;
int tm_hour;
int tm_mday;
int tm_mon;
int tm_year;
int tm_wday;
int tm_yday;
int tm_isdst;
}
Description of each element is :
tm_sec seconds after the minute 0-61
tm_min minutes after the hour 0-59
tm_hour hours since midnight 0-23
tm_mday day of the month 0-31
tm_mon month since january 0-11
tm_year years since 1900
tm_wday weekday(days since sunday) 0-6
tm_yday yearday(days since Jan10 0-365
tm_isdst daylight saving time flag
The Daylight Saving Time flag (tm_isdst) is greater than zero if Daylight Saving Time is in effect, zero if Daylight Saving Time is not in effect, and less than zero if the information is not available.
* tm_sec is generally 0-59. Extra range to accommodate for leap seconds in certain systems
Example:
/* time example */
#include <stdio.h>
#include <time.h>
#include <conio.h>
int main ()
{
time_t rawtime;
rawtime = time (NULL);
printf ("current time is :%s", ctime(&rawtime));
struct tm *mytime;
mytime = localtime(&rawtime);
printf ("current time is :%s",asctime(mytime));
printf("%d %d %d %d %d %d %d %d %d",mytime->tm_year,mytime->tm_mon ,mytime->tm_yday,mytime->tm_mday, \
mytime->tm_mday ,mytime->tm_hour , \
mytime->tm_min , \
mytime->tm_sec , \
mytime->tm_isdst);
getch();
return 0;
}
Thursday, January 1, 2009
Subscribe to:
Post Comments (Atom)

0 comments:
Post a Comment