函数是一个内置函数,它将格里高利历日期转换为儒略日计数。该函数接受格式为$month / $day / $year的三个参数,表示公历中的日期并将其转换为儒略日计数。
语法如下:
gregoriantojd( $month, $day, $year)
参数:该函数接受三个必选参数, 如上所示和以下内容:
- $ month –此参数指定公历中的月份数。月数范围为1到12(含)之间。如果通过的月份数超过12或小于0, 则儒略日返回为0。
- $ day –此参数指定公历中的日期。天数的范围是1-31(含)。如果经过的天数大于31或小于0, 则返回儒略日为0。不考虑Le年
- $ year –此参数指定公历中的年份。
- 返回值:该函数返回转换为儒略日计数的公历日期。
例子:
Input : $month=3, $day=31, $year=2018
Output : 2458209
Input : $month=4, $day=27, $year=2018
Output : 2458236
下面的程序说明了gregoriantojd()函数。
程序1:下面的程序演示了gregoriantojd()函数的用法。
<?php
// PHP program to demonstrate the
// use of gregoriantojd() function
// converts date to julian integer
$jd =gregoriantojd(4, 27, 2018);
// prints the julian day integer
echo ( $jd );
?>
输出如下:
2458236
程序2:下面的程序演示了何时超出日期和月份。
<?php
// PHP program to demonstrate the
// use of gregoriantojd() function
// converts date to julian integer
// month is out of range
$jd =gregoriantojd(4, 32, 2018);
// prints the julian day integer
echo ( $jd ), "\n" ;
// day is out of range
$jd =gregoriantojd(13, 29, 2018);
echo ( $jd );
?>
输出如下:
0
0
参考:http://php.net/manual/en/function.gregoriantojd.php
更多PHP开发相关内容请参考:lsbin - IT开发技术:https://www.lsbin.com/
参考更多以下PHP的内容: