PHP: jdtounix - Manual

downloads | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | conferences | my php.net

search for in the

JewishToJD JDToJulian

Last updated: Fri, 26 Jan 2007

view this page in

# jdtounix

(PHP 4, PHP 5)

jdtounix -- Convert Julian Day to Unix timestamp

## Description

int jdtounix ( int jday )

This function will return a Unix timestamp corresponding to the Julian Day given in `jday` or `FALSE` if `jday` is not inside the Unix epoch (Gregorian years between 1970 and 2037 or 2440588 <= `jday` <= 2465342 ). The time returned is localtime (and not GMT).

See also unixtojd().

add a note User Contributed Notes
jdtounix
erelsgl dot NOSPAM at cs dot technion dot ac dot il
19-Sep-2006 06:31
`Just to clarify the differences between the different methods to convert a date to a timestamp.
Suppose:
<?php
$x = JDToUnix(GregorianToJD(9,23,2006));
$y = strtotime('2006-09-23');
$z = (GregorianToJD(9,23,2006) - 2440587.5) * 86400;
?>
Then, on a machine whoze timezone is GMT-0400, we get the following results:
<?php
$x === 1158969600;
$y === 1158984000; // $x + 4 hours
$z === 1159012800; // $x + 12 hours
?>`
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.`
add a note
JewishToJD JDToJulian

Last updated: Fri, 26 Jan 2007
show source | credits | stats | sitemap | contact | advertising | mirror sites
Copyright © 2001-2007 The PHP Group
All rights reserved.
This mirror generously provided by: Yahoo! Inc.
Last updated: Sat Mar 10 09:32:46 2007 PST