Store Time Using the 64-Bit time_t Data Type

In C and C++, time is stored as a positive integer that contains the number of seconds elapsed since January 1st, 1970. The standard type time_t (defined in the header , for C) is a machine-dependent signed integral type that has at least 32 bits. As large as this unit may seem, on 32-bit architectures time_t will roll over on January 18, 2038. Consequently, applications that use time measurements beyond that date (mortgage calculations, pension and health insurance, and so on) might encounter undefined behavior. Before this problem becomes critical, hardware architectures need to switch to a 64-bit time_t, which is sufficiently large to represent billions of years. To examine the size of time_t on your machine, simply use the expression sizeof(time_t).

Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: