Conversion from UNIX time to timestamp starting in January 1, 2000 Conversion from UNIX time to timestamp starting in January 1, 2000 unix unix

Conversion from UNIX time to timestamp starting in January 1, 2000


The time 1 January 1970 00:00:00 is considered the UNIX epoch. So, if you want to convert from UNIX time to a timestamp having an epoch of January 1, 2000 (Let's say, 2000 epoch) the simplest way would be to simply subtract the UNIX time of January 1, 2000 from the UNIX time.

<2000 time> = <UNIX time> - <January 1, 2000 UNIX time><UNIX time> = <2000 time> + <January 1, 2000 UNIX time>

Where January 1, 2000 UNIX time is 946684800.

EDIT: The docs does say

Absolute time is measured in seconds from midnight, 1st January 2000.

So, 946684800 is the exact time difference which should be used to calculate. The few seconds difference that you calculated could be attributed to network delay or some other delays.


EDIT: The OP added details specifying that the time starts at midnight and hence it is absolute time different from J2000 which starts at noon. But since the title states "timestamp starting in January 1, 2000" I am letting this answer to be for future answer seekers.

ANSWER:

The timestamp you have mentioned appears to be the J2000.0 mentioned here

Since the Unix and J2000 epoch times are constants, you could define a constant to store the difference.

If you have a mathematical inclination the following links provide some info regarding the conversion

  1. http://www.giss.nasa.gov/tools/mars24/help/algorithm.html Refer to step A-2
  2. http://onegeek.org/software/smeg/current/src/time.c (C file),

    the #define section in the C file contains the following

    #define J2000 2451545.0 /* you-know-when */

    #define U1970 -10957.5 /* unix epoch relative to J2000 */


Well, there are 946684800 seconds between 2000-01-01T00:00:00Z and 1970-01-01T00:00:00Z. So, you can just set a constant for 946684800 and add or subtract from your Unix timestamps.

The variation you are seeing in your numbers has to do with the delay in sending and receiving the data, and could also be due to clock synchronization, or lack thereof. Since these are whole seconds, and your numbers are 3 to 4 seconds off, then I would guess that the clocks between your computer and your device are also 3 to 4 seconds out of sync.