Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Convert unix timestamp to julian

Tags:

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...

like image 837
bgoncalves Avatar asked Jan 21 '09 17:01

bgoncalves


People also ask

Is Unix timestamp a UTC?

Unix timestamps are always based on UTC (otherwise known as GMT). It is illogical to think of a Unix timestamp as being in any particular time zone. Unix timestamps do not account for leap seconds.

What is Julian timestamp?

“Julian Days” is a numerical timestamp format, calculated by Sea-Bird Scientific CTDs as the number of the days since Jan 1 of that year (e.g., noon on Feb 3 = 34.5). While this format is useful, it is usually more convenient to display data in a visual format such as “2020-02-03 12:00:00″.

Is Unix Epoch time UTC?

The Unix epoch (or Unix time or POSIX time or Unix timestamp) is the number of seconds that have elapsed since January 1, 1970 (midnight UTC/GMT), not counting leap seconds (in ISO 8601: 1970-01-01T00:00:00Z).


1 Answers

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; } 
like image 134
Jason Cohen Avatar answered Oct 22 '22 02:10

Jason Cohen