note 74199 added to function.jdtounix
| From: | hrabi at linuxwaves dot com | Date: | Thu, 29 Mar 2007 15:16:26 +0000 |
| Subject: | note 74199 added to function.jdtounix | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-124923@lists.php.net to get a copy of this message | ||
Beware, jd here is not (astronomical or geocentric) Julian Day (JD), but Chronological Julian Day
(CJD)! When JD start at noon of UTC time (12:00 UTC), CJD start at midnight at *local* time! Or
considering head "Chronlogical Julian Day/Date" at "http://www.decimaltime.hynes.net/dates.html",
when day localy start (it should be at sunset for instance).
try this...
<?php
define("UJD", 2440587.5);
define("SEC4DAY", 86400);
function u2j($tm) {
return $tm / SEC4DAY + UJD;
}
function mmd($txt, $str_time) {
$t = strtotime($str_time);
$j = unixtojd($t);
$j_fabio = u2j($t);
$s = strftime('%D %T %Z', $t);
printf("${txt} => %s, CJD: %s, JD: %s<br>\n", $s, $j, $j_fabio);
}
$xt = strtotime("1.1.1970 0:00.00 GMT");
$slb = "-1 day 23:30"; // let CJD be N
$sla = "0:30.00"; // should be N+1
$slm = "0:00"; // should be N+1
$sgmt = "0:00.00 GMT"; // don't forget to observe JD.
mmd("local before", $slb);
mmd("local after", $sla);
mmd("local midnight", $slm);
mmd("GMT midnight", $sgmt);
?>
I got this (you see, JD havn't change day, because UTC noon is far away):
local before => 03/28/07 23:30:00 CEST, CJD: 2454188, JD: 2454188.39583
local after => 03/29/07 00:30:00 CEST, CJD: 2454189, JD: 2454188.4375
local midnight => 03/29/07 00:00:00 CEST, CJD: 2454189, JD: 2454188.41667
GMT midnight => 03/29/07 02:00:00 CEST, CJD: 2454189, JD: 2454188.5
----
Server IP: 212.24.129.110
Probable Submitter: 217.198.112.101
----
Manual Page -- http://www.php.net/manual/en/function.jdtounix.php
Edit -- https://master.php.net/note/edit/74199
Del: integrated -- https://master.php.net/note/delete/74199/integrated
Del: useless -- https://master.php.net/note/delete/74199/useless
Del: bad code -- https://master.php.net/note/delete/74199/bad+code
Del: spam -- https://master.php.net/note/delete/74199/spam
Del: non-english -- https://master.php.net/note/delete/74199/non-english
Del: in docs -- https://master.php.net/note/delete/74199/in+docs
Del: other reasons-- https://master.php.net/note/delete/74199
Reject -- https://master.php.net/note/reject/74199
Search -- https://master.php.net/manage/user-notes.php