Name

tm struct — Represents the parts of a date and time

Synopsis

struct tm {
  int tm_sec;   /* Seconds: 0-61 */
  int tm_min;   /* Minutes: 0-59 */
  int tm_hour;  /* Hours:   0-23 */
  int tm_mday;  /* Day of month: 1-31 */
  int tm_mon;   /* Month: 0-11 */
  int tm_year;  /* Years since 1900 */
  int tm_wday;  /* Days since Sunday: 0-6 */
  int tm_yday;  /* Days since January 1: 0-365 */
  int tm_isdst; /* Daylight Savings Time */
}

The tm structure stores parts of a date and time. The values returned by localtime and gmtime will always be in the ranges shown above. (Note that two extra leap seconds are allowed for tm_sec.)

The tm_isdst member is positive when Daylight Savings Time is in effect, 0 when it is not in effect, or negative if it is unknown.

image with no caption

The order of the members is implementation-defined. An implementation can have additional members.

Get C++ In a Nutshell now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.