Defining the Date and Time Data Type

Originally, the UNIX time and date value was stored in the C data type long. As time passed, and as standardization efforts got underway, it was recognized that this was not good for long-range planning. The capacity of the long integer was going to run out someday (January 19, 2038, at 03:14:07 UTC, to be precise). The next second after that will cause the 31-bit positive number to roll over to a 32-bit value, making it a negative number.

Since the long integer data type was going to overflow in the near future, it was decided that date and time deserved its own special data type: time_t. This permits the underlying data type to be changed at a future date, requiring that applications only be recompiled. ...

Get Advanced UNIX Programming 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.