PHP如何使用cal_to_jd()函数?示例

2021年3月19日17:05:24 发表评论 638 次浏览

cal_to_jd()函数是PHP中的内置函数, 用于将指定的日期转换为儒略日计数。cal_to_jd()函数计算指定日历中日期的儒略日计数。此函数支持CAL_GREGORIAN, CAL_JULIAN, CAL_JEWISH和CAL_FRENCH标尺。

语法如下:

int cal_to_jd( $calendar, $month, $day, $year )

参数:该函数接受上述和以下所述的四个参数:

  • $日历:用于指定计算日历。日历值是公历, 法国日历, 犹太日历和朱利安日历。
  • 月:用于在所选日历中指定月份。
  • $ day:用于在所选日历中指定日期。
  • 年:用于在所选日历中指定年份。

返回值:此函数返回儒略日数。

下面的程序说明了PHP中的cal_to_jd()函数。

程序1:

<?php
      
// Converts a Gregorian calender Date 
// into Julian Day number.
$date = cal_to_jd(CAL_GREGORIAN, 11, 03, 2007);
  
// Prints the conversion of date to 
// Julain Day number.
echo $date ;
?>

输出如下:

2454408

程式2:

<?php
  
// Converts Julian calender Date into 
// Julian Day count.
$date = cal_to_jd(CAL_JULIAN, 7, 20, 20017);
  
// Prints the above conversion.
echo $date ;
?>

输出如下:

9032468

相关文章:

  • PHP | cal_days_in_month()函数
  • PHP | Easter_days()函数

参考: http://php.net/manual/en/function.cal-to-jd.php


木子山

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen: