Julian day from DateTime
Is there a better way of converting a DateTime object to a Julian day number than something like this:
$jd = GregorianToJD( $dt->format('n'), $dt->format('j'), $dt->format('Y') );
I'm a bit surprised there isn't either a function to do it directly or a format specifier to print it. Am I missing something obvious?
Edit: Many of the (somewhat sarcastic) replies below seem to be assuming the Julian day number is somehow related to the long-obsolete Julian calendar. It isn't. The Julian day number is one of the most common ways of numbering days from a fairly arbitrary epoch. Its main use is in astronomy where it is the standard way of identifying a date.
This should do the trick:
// $dt = new DateTime();
$jd = unixtojd( $dt->getTimestamp());
See more on unixtojd on PHP.net
链接地址: http://www.djcxy.com/p/24288.html上一篇: 对于readme.txt,nuget pack在csproj上的行为不像预期的那样
下一篇: 来自DateTime的Julian日