time() and GetTickCount() in C

In C language,
time() function returns a value of the current time in seconds from 1st January, 1970 UTC.
If you want the absolute time from 1st January, 1900 UTC in seconds (may be required in some network packet transmissions), then u can simply add the following unsigned int value to time():

const unsigned int from1900Till1970 = (unsigned int) 2208988800ul;
time_1900 = time() + from1900Till1970;

This absolute time values will continue without problem till 2036(The 32bit return value can go upto that period). After that we’ll see what happens. Mostly this concept of absolute time will go by then.

GetTickCount() function returns the time since your system booted up, in milliseconds. Hence it is not an absolute value. It returns a 16bit unsigned int value. There is a possibility of Rollback. On a Windows machine, the Rollback will occur if the system is ON continuously for approx. 49.7 days. Rare possibility but it exists.


What do you think??

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s