WaltP
Posting Sage w/ dash of thyme
11,404 posts since May 2006
Reputation Points: 3,421
Solved Threads: 1,055
Skill Endorsements: 37
Check this out
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 */
};
The members of the tm structure are:
tm_sec The number of seconds after the minute, normally in the range
0 to 59, but can be up to 60 to allow for leap seconds.
tm_min The number of minutes after the hour, in the range 0 to 59.
tm_hour The number of hours past midnight, in the range 0 to 23.
tm_mday The day of the month, in the range 1 to 31.
tm_mon The number of months since January, in the range 0 to 11.
tm_year The number of years since 1900.
tm_wday The number of days since Sunday, in the range 0 to 6.
tm_yday The number of days since January 1, in the range 0 to 365.
tm_isdst A flag that indicates whether daylight saving time is in
effect at the time described. The value is positive if day‐
light saving time is in effect, zero if it is not, and nega‐
tive if the information is not available.
Or this web site which took me 30 secs to find
http://www.cplusplus.com/reference/clibrary/ctime/tm/
gerard4143
Nearly a Posting Maven
2,295 posts since Jan 2008
Reputation Points: 512
Solved Threads: 397
Skill Endorsements: 0
how to use:
1. call time() to get current date/time as number of seconds since 1 Jan 1970.
2. call localtime() to get struct tm pointer. If you want GMT them call gmtime() instead of localtime()
3. Use sprintf() or strftime() to convert the struct tm to a string in any format you want.
Ancient Dragon
Achieved Level 70
32,157 posts since Aug 2005
Reputation Points: 5,836
Solved Threads: 2,577
Skill Endorsements: 69