ฟังก์ชั่น unixtojd()
ความหมายของฟังก์ชั่นและการใช้งาน
การแปลง unix timestamp เป็นวันในระบบ Julian Day ด้วยฟังก์ชั่น unixtojd()
รูปแบบการเขียน (Syntax)
- ถ้าไม่มีการกำหนด timestamp ลงไป จะใช้ timestamp ปัจจุบัน
int unixtojd ([ int $timestamp = time() ] )
ตัวอย่างที่ 1
<?php
function mmd($txt, $str_time) {
$t = strtotime($str_time);
$j = unixtojd($t);
$s = gmstrftime('%D %T %Z', $t);
$j_fabio = $t / 86400 + 2440587.5;
printf("${txt} => (%s) %s, %s U, %s J, or %s J<br>\n", $str_time, $s, $t, $j, $j_fabio);
}
//$xt = strtotime("1.1.1970 15:00.00 GMT");
$sam = "9.10.1995 02:00.01 GMT";
$spm = "9.10.1995 22:00.01 GMT";
// unixtojd for $spm returns 2450000 (OK), but for $sam returns 2450000 too! (it is wrong).
mmd("am", $sam); // should be 2449999 (+ 0.58334)
mmd("pm", $spm); // should be 2450000 (+ 0.41668)
?>