当前位置: 首页 > 网络学院 > 服务端脚本教程 > PHP > PHP Calendar
The calendar functions are useful when working with different calendar formats. The standard it is based on is the Julian day count (Julian day count is a count of days starting from January 1, 4713 B.C.). Note that the Julian day count is not the same as the Julian calendar!
日历扩展是由一系列简单的日历格式转换函数组成。媒介或标准是基于儒略日计数(Julian Day Count)。儒略日计数是从公元前 4713 年 1 月 1 日开始计算的。儒略日计数与罗马儒略历(Julian Calendar)完全不同!
Note: To convert between calendar formats, you must first convert to Julian day count, then to the calendar format.
注意:在不同的日历系统中转换,必须先将其转换为儒略日计数,然后转换为目标日历格式。
The windows version of PHP has built-in support for the calendar extension. So, the calendar functions will work automatically.
PHP 的 Windows 版本已经内置该扩展模块的支持。无需加载任何附加扩展库即可使用这些函数。
However, if you are running the Linux version of PHP, you will have to compile PHP with --enable-calendar to get the calendar functions to work.
但要在Linux版本的PHP中使用本类函数,需要在编译 PHP 时加上 --enable-calendar。
PHP: indicates the earliest version of PHP that supports the function.
PHP:最早支持这些函数的PHP版本
Function 函数 | Description 说明 | PHP |
---|---|---|
cal_days_in_month() | Returns the number of days in a month for a specified year and calendar 返回指定日历、年份的某个月份的天数 | 4 |
cal_from_jd() | Converts a Julian day count into a date of a specified calendar 将儒略[Julian]日计数转为其它日历的日期 | 4 |
cal_info() | Returns information about a given calendar 返回指定日历的信息 | 4 |
cal_to_jd() | Converts a date to Julian day count 将指定日期转为儒略日计数 | 4 |
easter_date() | Returns the Unix timestamp for midnight on Easter of a specified year 返回指定年份的复活节午夜的Unix时间戳 | 3 |
easter_days() | Returns the number of days after March 21, on which Easter falls for a specified year 返回指定年份的某一天超过3月21日复活节的天数 | 3 |
FrenchToJD() | Converts a French Republican date to a Julian day count 将法国共和历转为儒略日计数 | 3 |
GregorianToJD() | Converts a Gregorian date to a Julian day count 将格里高里历转为儒略日计数 | 3 |
JDDayOfWeek() | Returns the day of a week 返回一周中的天数 | 3 |
JDMonthName() | Returns a month name 返回月份的名字 | 3 |
JDToFrench() | Converts a Julian day count to a French Republican date 将儒略日计数转为法国共和历 | 3 |
JDToGregorian() | Converts a Julian day count to a Gregorian date 将儒略日计数转为格里高里历 | 3 |
jdtojewish() | Converts a Julian day count to a Jewish date 将儒略日计数转为犹太历 | 3 |
JDToJulian() | Converts a Julian day count to a Julian date 将儒略日计数转为罗马儒略历 | 3 |
jdtounix() | Converts a Julian day count to a Unix timestamp 将儒略日计数转为Unix时间戳 | 4 |
JewishToJD() | Converts a Jewish date to a Julian day count 将犹太历转为儒略日计数 | 3 |
JulianToJD() | Converts a Julian date to a Julian day count 将罗马儒略历转为儒略日计数 | 3 |
unixtojd() | Converts a Unix timestamp to a Julian day count 将Unix时间戳转为儒略日计数 | 4 |
PHP: indicates the earliest version of PHP that supports the constant.
PHP:下面列举了最早支持这些函数的PHP版本:
Constant 常量 | Description 说明 | PHP |
---|---|---|
CAL_GREGORIAN | Gregorian calendar 格里高里历 | 3 |
CAL_JULIAN | Julian calendar 罗马儒略历 | 3 |
CAL_JEWISH | Jewish calendar 犹太历 | 3 |
CAL_FRENCH | French Republican calendar 法国共和历 | 3 |
CAL_NUM_CALS | 3 | |
CAL_DOW_DAYNO | 3 | |
CAL_DOW_SHORT | 3 | |
CAL_DOW_LONG | 3 | |
CAL_MONTH_GREGORIAN_SHORT | 3 | |
CAL_MONTH_GREGORIAN_LONG | 3 | |
CAL_MONTH_JULIAN_SHORT | 3 | |
CAL_MONTH_JULIAN_LONG | 3 | |
CAL_MONTH_JEWISH | 3 | |
CAL_MONTH_FRENCH | 3 | |
CAL_EASTER_DEFAULT | 4 | |
CAL_EASTER_DEFAULT | 4 | |
CAL_EASTER_ROMAN | 4 | |
CAL_EASTER_ALWAYS_GREGORIAN | 4 | |
CAL_EASTER_ALWAYS_JULIAN | 4 | |
CAL_JEWISH_ADD_ALAFIM_GERESH | 5 | |
CAL_JEWISH_ADD_ALAFIM | 5 | |
CAL_JEWISH_ADD_GERESHAYIM | 5 |