The php gregoriantojd() and jdtogregorian() functions, in addition to the limitations noted by httpwebwitch, does not take account of the 'Astronomical' system of reckoning - i.e. using a year zero, instead of going directly from 1BCE to 1CE, as with the Christian Anno Domini system.
These functions can be used to wrap the php built-ins to return ISO 8601 compliant dates:
<?php
function ISO8601toJD($ceDate) {
list($day, $month, $year) = array_map('strrev',explode('-', strrev($ceDate), 3));
if ($year <= 0) $year--;
return gregoriantojd($month, $day, $year);
}
function JDtoISO8601($JD) {
if ($JD <= 1721425) $JD += 365;
list($month, $day, $year) = explode('/', jdtogregorian($JD));
return sprintf('%+05d-%02d-%02d', $year, $month, $day);
}
?>