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.