PHP 日历函数

PHP jdtojulian() 函数将儒略日计数转换为儒略历日期。该函数采用儒略日整数,并以"月/日/年"形式的字符串形式返回转换后的儒略历日期。

语法

jdtojulian(julian_day) 

参数

julian_day必填。 将儒略日数字指定为整数。

返回值

以字符串形式返回儒略历日期格式为"月/日/年"。

例外

无。

示例:

下面的示例显示了 jdtojulian() 函数的用法。

<?php
//转换儒略历日期
//转为儒略整数
$jd = juliantojd(10, 2, 2015);
  
//显示儒略日整数
echo "The Julian day integer is: $jd \n";
  
//转换儒略日整数
//转为儒略历日期
$date = jdtojulian($jd);
  
//显示儒略历日期
echo "The Julian Calendar Date is: $date \n"; 
?> 

上述代码的输出将是:

The Julian day integer is: 2457311 
The Julian Calendar Date is: 10/2/2015 

示例:溢出行为

再考虑一个示例来查看此函数的溢出行为。

<?php
//转换无效的儒略历
//日期转儒略整数
$jd = juliantojd(15, 2, 2018);
  
//打印 0,因为月份超出范围
echo "The Julian day integer is: $jd \n";
  
//转换儒略日整数
//转为儒略历日期
$date = jdtojulian($jd);
  
//打印 0/0/0 作为儒略历
//月份超出范围
echo "The Julian Calendar Date is: $date \n"; 
?> 

上述代码的输出将是:

The Julian day integer is: 0 
The Julian Calendar Date is: 0/0/0