PHP | gregoriantojd()函数

gregoriantojd()函数是一个内置函数,用于转换 格里高利日期 朱利安日计数 .该函数接受格式为的三个参数 $month/$day/$year ,表示公历中的日期,并将其转换为儒略日计数。

null

语法:

gregoriantojd( $month, $day, $year) 

参数: 该函数接受三个强制参数,如下所示:

  1. 每月美元- 此参数指定公历中的月数。月数在1-12之间(含1-12)。如果一个月数超过12或小于0,则儒略日返回为0。
  2. $day– 此参数指定公历中的日期。日数在1-31之间(含1-31)。如果通过的日数超过31或小于0,则朱利安日返回为0。闰年没有考虑在内
  3. 美元年- 此参数指定公历中的年份。

    返回值: 该函数返回转换为朱利安日计数的公历日期。

    例如:

    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 ), "" ;
    // day is out of range
    $jd =gregoriantojd(13, 29, 2018);
    echo ( $jd );
    ?>

    
    

    输出:

    0
    0

    参考: http://php.net/manual/en/function.gregoriantojd.php

© 版权声明
THE END
喜欢就支持一下吧
点赞6 分享