PHP Calendar 函数
PHP Calendar 函数
PHP Calendar 简介
日历扩展包含了简化不同日历格式间转换的函数。
它基于 Julian Day Count(儒略日计数),是从公元前 4713 年 1 月 1 日开始计日的。
注释:如需在日历格式之间转换,您必须首先转换为 Julian Day Count,然后再转换为您选择的日历格式。
注释:Julian Day Count(儒略日计数)与 Julian Calendar(儒略历法) 不是一回事!
安装
为了让这些函数能够工作,您必须通过 --enable-calendar 编译 PHP。
PHP 的 Windows 版本已内建了对日历扩展的支持。因此,Calendar 函数会自动工作。
PHP 5 Calendar 函数
函数 | 描述 |
---|---|
cal-days-in-month() | 针对指定的年份和历法,返回一个月中的天数。 |
cal-from-jd() | 把儒略日计数转换为指定历法的日期。 |
cal-info() | 返回有关指定历法的信息。 |
cal-to-jd() | 把指定历法中的日期转换为儒略日计数。 |
easter-date() | 返回指定年份的复活节午夜的 Unix 时间戳。 |
easter-days() | 返回指定年份的复活节与 3 月 21 日之间的天数。 |
frenchtojd() | 把法国共和历的日期转换成为儒略日计数。 |
gregoriantojd() | 把格利高里历法的日期转换成为儒略日计数。 |
jddayofweek() | 返回日期在周几。 |
jdmonthname() | 返回月的名称。 |
jdtofrench() | 把儒略日计数转换为法国共和历的日期。 |
jdtogregorian() | 将格利高里历法转换成为儒略日计数。 |
jdtojewish() | 把儒略日计数转换为犹太历法的日期。 |
jdtojulian() | 把儒略日计数转换为儒略历法的日期。 |
jdtounix() | 把儒略日计数转换为 Unix 时间戳。 |
jewishtojd() | 把犹太历法的日期转换为儒略日计数。 |
juliantojd() | 把儒略历法的日期转换为儒略日计数。 |
unixtojd() | 把 Unix 时间戳转换为儒略日计数。 |
PHP 5 预定义的 Calendar 常量
常量 | 类型 | PHP 版本 |
---|---|---|
CAL-GREGORIAN | Integer | PHP 4 |
CAL-JULIAN | Integer | PHP 4 |
CAL-JEWISH | Integer | PHP 4 |
CAL-FRENCH | Integer | PHP 4 |
CAL-NUM-CALS | Integer | PHP 4 |
CAL-DOW-DAYNO | Integer | PHP 4 |
CAL-DOW-SHORT | Integer | PHP 4 |
CAL-DOW-LONG | Integer | PHP 4 |
CAL-MONTH-GREGORIAN-SHORT | Integer | PHP 4 |
CAL-MONTH-GREGORIAN-LONG | Integer | PHP 4 |
CAL-MONTH-JULIAN-SHORT | Integer | PHP 4 |
CAL-MONTH-JULIAN-LONG | Integer | PHP 4 |
CAL-MONTH-JEWISH | Integer | PHP 4 |
CAL-MONTH-FRENCH | Integer | PHP 4 |
CAL-EASTER-DEFAULT | Integer | PHP 4.3 |
CAL-EASTER-ROMAN | Integer | PHP 4.3 |
CAL-EASTER-ALWAYS-GREGORIAN | Integer | PHP 4.3 |
CAL-EASTER-ALWAYS-JULIAN | Integer | PHP 4.3 |
CAL-JEWISH-ADD-ALAFIM-GERESH | Integer | PHP 5.0 |
CAL-JEWISH-ADD-ALAFIM | Integer | PHP 5.0 |
CAL-JEWISH-ADD-GERESHAYIM | Integer | PHP 5.0 |