note 110124 deleted from function.unixtojd by danbrown
| From: | danbrown@php.net | Date: | Thu, 06 Dec 2012 15:15:40 +0000 |
| Subject: | note 110124 deleted from function.unixtojd by danbrown | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-192362@lists.php.net to get a copy of this message | ||
Note Submitter: alexsand3 at gmail dot com
----
<?php
function getJulianDay($time) {
date_default_timezone_set('UTC');
$date = getdate($time);
$frac = $date['mday'] + (($date['hours'] + ($date['minutes'] / 60) +
($date['seconds'] / 60 / 60)) / 24);
if($date['year'] < 1582) $greg = 0;
else $greg = 1;
if(($date['mon'] == 1) || ($date['mon'] == 2)) {
$date['year'] = $date['year'] - 1;
$date['mon'] = $date['mon'] + 12;
}
$a = floor($date['year'] / 100);
$b = (2 - $a + floor($a / 4)) * $greg;
if($date['year'] < 0) $c = floor((365.25 * $date['year']) - 0.75);
else $c = floor(365.25 * $date['year']);
$d = floor(30.6001 * ($date['mon'] + 1));
$jd = $b + $c + $d + 1720994.5;
$jd = $jd + $frac;
return $jd;
}
?>
source http://www.smokycogs.com/blog/astronomical-calculations-in-c-sharp-the-julian-day/