PHP: unixtojd - Manual

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

search for in the

CCVS JulianToJD

Last updated: Fri, 26 Jan 2007

view this page in

# unixtojd

(PHP 4, PHP 5)

unixtojd -- Convert Unix timestamp to Julian Day

## Description

int unixtojd ( [int timestamp] )

Return the Julian Day for a Unix `timestamp` (seconds since 1.1.1970), or for the current day if no `timestamp` is given.

See also jdtounix().

add a note User Contributed Notes
unixtojd
fabio at llgp dot org
31-Aug-2006 02:09
`If you need an easy way to convert an unix timestamp to a decimal julian day you can use:
$julianDay = $unixTimeStamp / 86400 + 2440587.5;
86400 is the number of seconds in a day;
2440587.5 is the julian day at 1/1/1970 0:00 UTC.`
10-Aug-2006 07:22
`Its clearly stated that this function returns the Julian Day, not Julian Day + time.
If you want the time with it you will have to do something like:
$t=time();
$jd=unixtojd($t)+($t%60*60*24)/60*60*24;`
warhog at warhog d0t net
12-Jul-2005 02:11
`Well, that's neither a bug, nor an interesting quirk.. The explanation is quite simple:
The Integer containing a julian date (jd) only stores the date, not the time. When you convert a unix-timestamp, which stores also the time, into a jd, the time-information won't be transferred into the jd. When converting back the jd into a unix-timestamp, you'll get a timestamp for the specific day at 2 o'clock am. ( 02:00:00 )
Sample:
Timestamp: 1121206013
JD: 2453565
Timestamp from JD: 1121212800
Original Timestamp "d.m.y H:i:s": 13.07.2005 00:06:53
Timstamp from JD "d.m.y H:i:s": 13.07.2005 02:00:00
greetz`
Mike
21-Dec-2004 08:57
`Interesting quirk ... maybe bug.
If you use today = unixtojd(time())
then use jdtounix(today) the result is one day short of today.`
johnston at capsaicin dot ca
19-Nov-2003 01:43
`Also note that epoch is in UTC time (epoch is a specific point in time - epoch is not different for every time zone), so be aware of timezone complexities.`
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
CCVS JulianToJD

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