CakeFest 2024: The Official CakePHP Conference

jdtounix

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

jdtounixユリウス歴を Unix タイムスタンプに変換する

説明

jdtounix(int $julian_day): int

この関数は、julian_day で指定したユリウス歴に 対応する Unix タイムスタンプを返します。 返される時刻はUTCです。

パラメータ

julian_day

64bit のシステムでは、2440588 から 106751993607888 までのユリウス積算日。 32bit のシステムでは、2440588 から 2465443 までの値です。

戻り値

指定したユリウス積算日の開始(昼ではなく夜中)時の Unix タイムスタンプを返します。

エラー / 例外

julian_day が範囲外の値の場合、 ValueError がスローされます。

変更履歴

バージョン 説明
8.0.0 この関数は、失敗時に false を返さなくなりました。 代わりに ValueError をスローするようになっています。
7.3.24, 7.4.12 julian_day の上限が拡張されました。 これより前のバージョンでは、アーキテクチャに関わらず、 2465342 が上限でした。

参考

  • unixtojd() - Unix タイムスタンプをユリウス歴に変換する

add a note

User Contributed Notes 5 notes

up
7
fabio at llgp dot org
17 years ago
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
up
3
Anonymous
19 years ago
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!!
up
0
seb at carbonauts dot com
20 years ago
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.
up
-2
Saeed Hubaishan
9 years ago
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
up
-2
pipian at pipian dot com
20 years ago
Remember that UNIX timestamps indicate a number of seconds from midnight of January 1, 1970 on the Gregorian calendar, not the Julian Calendar.
To Top