gregoriantojd()函數是將公曆日期轉換為儒略日計數的內置函數。該函數接受$month /$day /$year格式的三個參數,該參數表示公曆中的日期並將其轉換為儒略日計數。
用法:
gregoriantojd( $month, $day, $year)
參數:該函數接受三個必選參數,如上所示和以下內容:
- $month - 此參數指定公曆中的月份數。月數範圍為1到12(含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
Reference:
http://php.net/manual/en/function.gregoriantojd.php
相關用法
- d3.js d3.map.set()用法及代碼示例
- PHP Ds\Map put()用法及代碼示例
- PHP end()用法及代碼示例
- PHP tan( )用法及代碼示例
- PHP pos()用法及代碼示例
- PHP cos( )用法及代碼示例
- CSS var()用法及代碼示例
- PHP sin( )用法及代碼示例
- PHP key()用法及代碼示例
- PHP abs()用法及代碼示例
- PHP each()用法及代碼示例
- p5.js min()用法及代碼示例
注:本文由純淨天空篩選整理自gopaldave大神的英文原創作品 PHP | gregoriantojd() Function。非經特殊聲明,原始代碼版權歸原作者所有,本譯文未經允許或授權,請勿轉載或複製。