List Info

Thread: note 74199 added to function.jdtounix




note 74199 added to function.jdtounix
user name
2007-03-29 10:16:26
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 "htt
p://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("$ => %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 -- ht
tp://www.php.net/manual/en/function.jdtounix.php
Edit        -- https://master
.php.net/note/edit/74199
Del: integrated  -- h
ttps://master.php.net/note/delete/74199/integrated
Del: useless     -- http
s://master.php.net/note/delete/74199/useless
Del: bad code    -- htt
ps://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     -- http
s://master.php.net/note/delete/74199/in+docs
Del: other reasons-- https://mast
er.php.net/note/delete/74199
Reject      -- https://mast
er.php.net/note/reject/74199
Search      -- https://
master.php.net/manage/user-notes.php

-- 
PHP Notes Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub
.php


[1]

about | contact  Other archives ( Real Estate discussion Medical topics )