UNIX time (POSIX time)
UNIX time is a time representation used internally by the computer. Although it is expressed in seconds, it may be handled in milliseconds.
- Use the number of seconds that have elapsed since the Unix epoch to represent the date and time.
- Unix Epoch is 00:00:00 UTC on 1 January 1970.
- Since it represents the date and time, the leap second is adjusted. Therefore, it does not represent the true number of seconds elapsed like GPS time.
Year 2038 problem
A problem that could cause some computers to malfunction after 03:14:07 UTC on 19 January 2038.
This date is 2147483647 seconds after the UNIX epoch, which is the maximum value for a 32-bit signed integer. Therefore, if UNIX time is handled as an int type, it may overflow in 2038 and malfunction.
Measure 1: Use a 64-bit signed integer (long). In this case, it will be usable until about 300 billion AD. By that time, the earth should be gone, so the way we measure time has changed, and it’s probably not a problem.
Measure 2: If for some reason you cannot use a 64-bit signed integer, you can use a 32-bit unsigned integer. In this case, it will be usable until 6:28:15 on February 7, 2106. Human beings may be extinct, but the earth is still there, so I would like to make it a 64-bit if possible.