datetimetimestampdatejulian-date

Convert unix timestamp to julian


How can I convert from a unix timestamp (say 1232559922) to a fractional julian date (2454853.03150).

I found a website ( http://aa.usno.navy.mil/data/docs/JulianDate.php ) that performs a similar calculation but I need to do it programatically.

Solutions can be in C/C++, python, perl, bash, etc...


Solution

  • The Unix epoch (zero-point) is January 1, 1970 GMT. That corresponds to the Julian day of 2440587.5

    So, in pseudo-code:

    function float getJulianFromUnix( int unixSecs )
    {
       return ( unixSecs / 86400.0 ) + 2440587.5;
    }