PHP frenchtojd()函数用法详细介绍

2021年3月16日12:15:08 发表评论 870 次浏览

函数frenchtojd()是一个内置函数,它将法国日期转换为儒略日计数。该函数接受三个格式的参数$ month / $ day / $ year, 它代表法国共和日历中的日期, 并将其转换为儒略日计数。

语法如下:

frenchtojd( $month, $day, $year)

参数:该函数接受三个必选参数, 如上所示和以下内容:

  1. $ month –此参数指定法语日历中的月份号。月数范围为1-13(含)。如果通过的月份数超过12或小于0, 则儒略日返回为0。
  2. $ day –此参数指定法国日历中的日期。天数在1到30之间(含1和30)。如果经过的天数大于31或小于0, 则返回儒略日为0。不考虑Le年
  3. $ year-此参数指定法语日历中的年份。年份范围为1-14(含)。如果超过了14或小于1的年份, 则返回儒略日为0。不考虑Le年

返回值:该函数返回转换为儒略日计数的法语日期。

例子:

Input : $month=3, $day=11, $year=12
Output : 2379928 

Input : $month=4, $day=8, $year=13
Output : 2380320

下面的程序说明了frenchtojd()函数。

程序1:下面的程序演示了frenchtojd()函数的用法。

<?php
// PHP program to demonstrate the
// use of frenchtojd() function 
  
// converts date to julian integer 
$jd =frenchtojd(4, 8, 13);
  
// prints the julian day integer
echo ( $jd );
?>

输出如下:

2380320

程式2:下面的程序演示了何时超出日期和月份。

<?php
// PHP program to demonstrate the
// use of frenchtojd() function 
  
// converts date to julian integer 
// month is out of range
$jd =frenchtojd(22, 8, 11);
  
// prints the julian day integer
echo ( $jd ), "\n" ; 
  
  
// day is out of range
$jd =frenchtojd(4, 32, 11);
echo ( $jd ); 
?>

输出如下:

0
0

参考:

http://php.net/manual/en/function.frenchtojd.php


木子山

发表评论

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