jddayofweek()函数是PHP中的一个内置函数,它返回参数中传递的Julian整数的给定星期几。根据函数中传递的模式,返回值有三种类型。它返回代表一周中某一天的三种类型的值。如果模式被传递为0,它将返回0、1、2…表示星期天、星期一、星期二…当1被传递为模式时,它将返回星期天、星期一、星期二。当2作为模式传递时,它返回缩写Sun、Mon、Tue…作为一周中的一天。
null
语法:
jddayofweek($jd, $mode)
参数: 该函数接受两个参数,如下所示。
- $jd –这是一个强制参数,将儒略日数指定为整数。公历日期通过以下方式转换为朱利安日整数: 格雷戈里安托加德( $month,$day,$year ) .
- $mode –这是一个可选参数,用于指定返回值的类型。它接受范围为0-2(含0-2)的值。默认值为0。以下介绍了三种返回模式:
- 0 –当模式被传递为0时,它返回0、1、2、3。。分别表示星期天、星期一、星期二……为一周中的一天。当没有模式参数丢失或传递任何超出范围的值时,这是模式的默认值。
- 1. –当模式传递为1时,它将返回星期天、星期一、星期二…
- 2. –当mode被传递为2时,它返回周日、周一、周二的缩写形式,即Sun、Mon、Tues。。
返回值: 该函数根据在参数中传递的模式值返回星期几,如上所述。 例如:
Input : $jd = 4/27/2018 , mode=0 Output : 5Input : $jd = 4/27/2018 , mode=1 Output : Friday
下面的程序说明了 jddayofweek() 作用 项目1: 下面的程序演示了未通过模式且采用默认模式时的输出。
php
<?php // PHP program to demonstrate the // use of jddayofweek() function // when second parameter is not passed // converts date to julian integer $jd =gregoriantojd(4, 27, 2018); // prints the day on the given date echo jddayofweek( $jd ); ?> |
输出:
5
项目2: 下面的程序演示了模式为1时的输出。
php
<?php // PHP program to demonstrate the // use of jddayofweek() function // when mode is 1 // converts date to julian integer $jd =gregoriantojd(4, 27, 2018); // prints the day on the given date echo jddayofweek( $jd , 1); ?> |
输出:
Friday
方案3: 下面的程序演示了模式为2时的输出。
php
<?php // PHP program to demonstrate the // use of jddayofweek() function // when mode is 2 // converts date to julian integer $jd =gregoriantojd(4, 27, 2018); // prints the day on the given date echo jddayofweek( $jd , 2); ?> |
输出:
Fri
方案4: 下面的程序演示了模式超出范围时的输出。
php
<?php // PHP program to demonstrate the // use of jddayofweek() function // when mode is out of range // converts date to julian integer $jd =gregoriantojd(4, 27, 2018); // prints the day on the given date echo jddayofweek( $jd , 4); ?> |
输出:
5
参考: http://php.net/manual/en/function.jddayofweek.php
© 版权声明
文章版权归作者所有,未经允许请勿转载。
THE END