devxlogo

Store Time Using the 64-Bit time_t Data Type

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).

devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist