The Year-2038 Bug


Home
Demo
Developers
64-bit
Contact

      A web site devoted to disseminating information about the year-2038 bug

An example C program

The following C program demonstrates this effect. It is strict ANSI C so it should compile on all systems that support an ANSI C compiler.

#include <stdlib.h>
#include <stdio.h>
#include <unistd.h>
#include <time.h>

int main (int argc, char **argv)
{
    time_t t;
    t = (time_t) 1000000000;
    printf ("%d, %s", (int) t, asctime (gmtime (&t)));
    t = (time_t) (0x7FFFFFFF);
    printf ("%d, %s", (int) t, asctime (gmtime (&t)));
    t++;
    printf ("%d, %s", (int) t, asctime (gmtime (&t)));
    return 0;
}

The program produces the output:

1000000000, Sun Sep  9 01:46:40 2001
2147483647, Tue Jan 19 03:14:07 2038
-2147483648, Fri Dec 13 20:45:52 1901