jdtounix

(PHP 4, PHP 5, PHP 7, PHP 8)

jdtounix转变Julian Day计数为一个Unix时间戳

说明

jdtounix ( int $jday ) : int

这个函数根据给定的julian天数返回一个Unix时间戳,或如果参数jday不在Unix时间(Gregorian历法的1970年至2037年,或2440588 <= jday <= 2465342)范围内返回 false 。返回的时间是本地时间(不是GMT)。

参数

jday

一个在 2440588 到 2465342 之间的julian天数

返回值

指定的julian天数的开始时的时间戳。

参见

  • unixtojd() - 转变Unix时间戳为Julian Day计数

User Contributed Notes

Saeed Hubaishan 22-Oct-2014 06:11
unixtojd() assumes that your timestamp is in GMT, but jdtounix() returns a timestamp in localtime.
so
<?php
$d1
=jdtogregorian(unixtojd(time()));
$d2= gmdate("m/d/Y");
$d3=date("m/d/Y");
?>
$d1 always equals $d2 but $d1 may differ from $d3
fabio at llgp dot org 31-Aug-2006 02:14
If you need an easy way to convert a decimal julian day to an unix timestamp you can use:

$unixTimeStamp = ($julianDay - 2440587.5) * 86400;

2440587.5 is the julian day at 1/1/1970 0:00 UTC
86400 is the number of seconds in a day
27-Jan-2005 06:50
Warning: the calender functions involving julian day operations seem to ignore the decimal part of the julian day count.

This means that the returned date is wrong 50% of the time, since a julian day starts at decimal .5 .  Take care!!
seb at carbonauts dot com 21-Oct-2003 12:10
Remember that unixtojd() assumes your timestamp is in GMT, but jdtounix() returns a timestamp in localtime.

This fooled me a few times. 

So if you have:

$timestamp1 = time();
$timestamp2 = jdtounix(unixtojd($timestamp1));

Unless your localtime is the same as GMT, $timestamp1 will not equal $timestamp2.
pipian at pipian dot com 12-Jun-2003 09:29
Remember that UNIX timestamps indicate a number of seconds from midnight of January 1, 1970 on the Gregorian calendar, not the Julian Calendar.
PHP8中文手册 站长在线 整理 版权归PHP文档组所有