PHP - jewishtojd() 函数



PHP 日历 jewishtojd() 函数用于将日期从希伯来历转换为儒略日数。它是从儒略历起始日期开始的连续天数计数。当处理希伯来历的日期并希望执行计算或比较时,此函数非常有用。

语法

以下是 PHP 日历 jewishtojd() 函数的语法:

int jewishtojd ( int $month , int $day , int $year )

参数

以下是 jewishtojd() 函数的参数:

  • $month - 月份,数字 1 到 13。

  • $day - 日期,数字 1 到 30。

  • $year - 年份,数字 1 到 9999。

返回值

jewishtojd() 函数返回给定希伯来历日期的儒略日,以整数形式表示。

PHP 版本

jewishtojd() 函数首次引入核心 PHP 4,并且在 PHP 5、PHP 7 和 PHP 8 中都能轻松使用。

示例 1

首先,我们将向您展示 PHP 日历 jewishtojd() 函数将希伯来历日期转换为儒略日数的基本示例。

<?php
   // Convert jewish to Julian Day count
   echo "The Julian Day Count is as follows: ";

   echo(jewishtojd(12,10,5060));
?>

输出

以下是以下代码的结果:

The Julian Day Count is as follows: 2196091

示例 2

此示例使用 convertToJulianDay() 函数将日期从希伯来历日期转换为儒略日数。

<?php
   // Create a function to convert jewish date to julian day count
   function convertToJulianDay($month, $day, $year) {
      return jewishtojd($month, $day, $year);
  }

   // Display the result
   echo "The converted date is as follows: ";
   echo convertToJulianDay(1, 1, 5784);
?> 

输出

这将产生以下输出:

The converted date is as follows: 2460204

示例 3

此示例演示如何开发一个简单的类,使用 jewishtojd() 函数将标准希伯来历日期 (1, 1, 5784) 转换为儒略日数。

<?php
   // Create a converter class
   class Converter {
    public function convertToJulianDay($month, $day, $year) {
        return jewishtojd($month, $day, $year);
    }
   }

   $converter = new Converter();
   echo $converter->convertToJulianDay(1, 1, 5784);
?> 

输出

这将生成以下输出:

2460204
php_function_reference.htm
广告

© . All rights reserved.