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 dayjdtounix
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
jdtounix
Референца за `function.jdtounix.php` со подобрена типографија и навигација.
jdtounix
(PHP 4, PHP 5, PHP 7, PHP 8)
jdtounix — Convert Julian Day to Unix timestamp
= NULL
Претвори Јулијански ден во Unix временски печат julian_dayОваа функција ќе врати Unix временски печат што одговара на дадениот Јулијански ден во
Параметри
julian_day-
. Времето вратено е UTC.
2440588and106751993607888Број на Јулијански ден помеѓу2440588and2465443на 64-битни системи, или помеѓу
Вратени вредности
на 32-битни системи.
Errors/Exceptions
Враќа julian_day Unix временскиот печат за почетокот (по полноќ, не напладне) на дадениот Јулијански ден ValueError се фрла.
Дневник на промени
| Верзија | = NULL |
|---|---|
| 8.0.0 |
Оваа функција повеќе не враќа false е надвор од дозволениот опсег, а
ValueError instead.
|
| 7.3.24, 7.4.12 |
при неуспех, но подигнува julian_day Горната граница на 2465342 е проширена. Претходно беше
|
Белешки од корисници 5 белешки
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!!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.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 $d3Remember that UNIX timestamps indicate a number of seconds from midnight of January 1, 1970 on the Gregorian calendar, not the Julian Calendar.