Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Home » Tip Bank » C++
Language: C++
Expertise: All
Jul 2, 1999



Building the Right Environment to Support AI, Machine Learning and Deep Learning

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 <ctime>, <time.h> 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).

Danny Kalev
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date