PHP 8.0.0 Released!

jdtounix

(PHP 4, PHP 5, PHP 7)

jdtounixConvert Julian Day to Unix timestamp

Description

jdtounix ( int $julian_day ) : int

This function will return a Unix timestamp corresponding to the Julian Day given in julian_day. The time returned is UTC.

Parameters

julian_day

A julian day number between 2440588 and 106751993607888 on 64bit systems, or between 2440588 and 2465443 on 32bit systems.

Return Values

The unix timestamp for the start (midnight, not noon) of the given Julian day

Errors/Exceptions

If julian_day is outside of the allowed range, a ValueError is thrown.

Changelog

Version Description
8.0.0 This function no longer returns FALSE on failure, but raises a ValueError instead.
7.3.24, 7.4.12 The upper limit of julian_day has been extended. Previously, it was 2465342 regardless of the architecture.

See Also

  • unixtojd() - Convert Unix timestamp to Julian Day

add a note add a note

User Contributed Notes 5 notes

up
5
fabio at llgp dot org
14 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
15 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
1
seb at carbonauts dot com
17 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
0
pipian at pipian dot com
17 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.
up
-1
Saeed Hubaishan
6 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
To Top