Timestamp

From Hackepedia
Jump to navigationJump to search

UNIX timestamp

A UNIX timestamp is a 32 bit signed integer that starts at January 1st, 1970 at 00:00 hours. This program shows what the size of time_t is on a UNIX system:

#include <sys/types.h>
#include <stdio.h>

int 
main(void) 
{ 
   printf("size time_t = %d\n",  sizeof(time_t));      
   return (0);
}

When executed it gives different results on the system:

dione$ uname -a ; ./time_t
OpenBSD dione.centroid.eu 4.9 GENERIC#477 amd64
size time_t = 4
pjp@miranda:~$ uname -a ; ./time_t
Linux miranda 2.6.38-8-generic #42-Ubuntu SMP Mon Apr 11  03:31:24 UTC 2011 x86_64 x86_64 x86_64 GNU/Linux
size time_t = 8

So why is time_t an 8 byte value on Ubuntu GNU/Linux? Well you may have heard of the 2038 problem, by extending the time_t value to 64 bits the 2038 problem will not affect any computer running with 64 bits timestamps.

Old UNIX computers should get a patch or forever be doomed on Tue Jan 19 04:14:07 2038 because the rollover may put the date to Fri Dec 13 21:45:52 1901. You guessed it, it's a similar problem to the year 2000 problem that some of us experienced.


Windows timestamp

Windows timestamps for dates in NTFS are 64 bit. No 2038 problem exists here.