gregoriantojd() converts a Gregorian calendar date to a Julian day count. If any parameter is set to a value outside of the acceptable range, the function returns 0.
The following table shows the acceptable ranges for the parameters of this function.
To specify a B.C. date, use a negative value for the year parameter.
This function is fairly forgiving in one way. If the date specified is invalid for the month specified, but still falls between 1 and 31, the function returns a valid Julian day count. The count is for the month after the specified month, with the day of the month set to the specified day minus the actual number of days in the specified month. Try the following example:
The Gregorian calendar has been in use for much of the western world for the last four centuries. It's basically the Julian calendar, with the slight modification that centennial years are not leap years (unless they are evenly divisible by 400).
To convert a Julian day count to a Gregorian calendar date:
To convert a Julian day count to another calendar system:
See the other jdto*() functions
// Parse the current month, day, and year out of a call to date () list ($month, $day, $year) = explode ('/', date ('m/d/Y')); echo gregoriantojd (12, 25, $year) - gregoriantojd ($month, $day, $year);
// Get a Julian day count for February 30th, 2003 $julian_day = gregoriantojd (2, 30, 2003); echo "The Julian day count for February 30, 2003 is $julian_day.<br />"; // Find the proper date for $julian_day // Parse the date in separate values for $year and $day. Discard the month data. list (, $day, $year) = explode ('/', jdtogregorian ($julian_day)); // Find the month name for $julian_day $month_name = jdmonthname ($julian_day, 1); echo "However, the proper date for this Julian day count is actually $month_name $day, $year.";
PHP Functions Essential Reference. Copyright © 2002 by New Riders Publishing (Authors: Zak Greant, Graeme Merrall, Torben Wilson, Brett Michlitsch). This material may be distributed only subject to the terms and conditions set forth in the Open Publication License, v1.0 or later (the latest version is presently available at http://www.opencontent.org/openpub/). The authors of this book have elected not to choose any options under the OPL. This online book was obtained from http://www.fooassociates.com/phpfer/ and is designed to provide information about the PHP programming language, focusing on PHP version 4.0.4 for the most part. The information is provided on an as-is basis, and no warranty or fitness is implied. All persons and entities shall have neither liability nor responsibility to any person or entity with respect to any loss or damage arising from the information contained in this book.