|
|
:rolleyes:
UNIX systems all use the same starting point for times and dates: [color="red"]midnight GMT on January 1, 1970.
This is the”start of the UNIX epoch” and Linux is no exception. All times in a Linux system are measured
as seconds since then. This is similar to the way MS-DOS handles times, except that the MS-DOS epoch
started in 1980. Other systems use other epoch start times.
Get a time value (structure: time_t) with time(),
then break it into details with gmtime(), or localtime(), get a structure tm.
Broken-down time is stored in the structure tm which is defined in <time.h> as follows:
struct tm {
int tm_sec; /* seconds */
int tm_min; /* minutes */
int tm_hour; /* hours */
int tm_mday; /* day of the month */
int tm_mon; /* month */
int tm_year; /* year */
int tm_wday; /* day of the week */
int tm_yday; /* day in the year */
int tm_isdst; /* daylight saving time */
};
tm Member Description
int tm_sec Seconds, 0-61
int tm_min Minutes, 0-59
int tm_hour Hours, 0-23
int tm_mday Day in the month, 1-31
int tm_mon Month in the year, 0-11(January= 0)
[color="red"]int tm_year Years since 1900 :rolleyes:
int tm_wday Day in the week, 0-6. (Sunday = 0)
int tm_yday Day in the year, 0-365
int tm_isdst Daylight savings in effect |
|