21xrx.com
2024-03-19 12:31:13 Tuesday
登录
文章检索 我的文章 写文章
PHP日期/时间函数
2021-08-30 16:46:26 深夜i     --     --
PHP日期/时间函数


 

日期/时间函数允许您从PHP脚本运行的服务器中获取日期和时间 。 然后,您可以使用日期/时间函数。

注意:这些函数取决于服务器的区域设置。。


安装

PHP日期/时间函数是PHP内核的一部分。 不需要另外安装。


运行时配置

 

Name Description Default PHP Version
date.timezone The default timezone (used by all date/time functions) "" PHP 5.1
date.default_latitude The default latitude (used by date_sunrise() and date_sunset())  "31.7667" PHP 5.0
date.default_longitude The default longitude (used by date_sunrise() and date_sunset()) "35.2333" PHP 5.0
date.sunrise_zenith The default sunrise zenith (used by date_sunrise() and date_sunset()) "90.83" PHP 5.0
date.sunset_zenith The default sunset zenith (used by date_sunrise() and date_sunset()) "90.83" PHP 5.0


PHP日期/时间函数

Function Description
checkdate() Validates a Gregorian date
date_add() Adds days, months, years, hours, minutes, and seconds to a date
date_create_from_format() Returns a new DateTime object formatted according to a specified format
date_create() Returns a new DateTime object
date_date_set() Sets a new date
date_default_timezone_get() Returns the default timezone used by all date/time functions
date_default_timezone_set() Sets the default timezone used by all date/time functions
date_diff() Returns the difference between two dates
date_format() Returns a date formatted according to a specified format
date_get_last_errors() Returns the warnings/errors found in a date string
date_interval_create_from_date_string() Sets up a DateInterval from the relative parts of the string
date_interval_format() Formats the interval
date_isodate_set() Sets the ISO date
date_modify() Modifies the timestamp
date_offset_get() Returns the timezone offset
date_parse_from_format() Returns an associative array with detailed info about a specified date, according to a specified format
date_parse() Returns an associative array with detailed info about a specified date
date_sub() Subtracts days, months, years, hours, minutes, and seconds from a date
date_sun_info() Returns an array containing info about sunset/sunrise and twilight begin/end, for a specified day and location
date_sunrise() Returns the sunrise time for a specified day and location
date_sunset() Returns the sunset time for a specified day and location
date_time_set() Sets the time
date_timestamp_get() Returns the Unix timestamp
date_timestamp_set() Sets the date and time based on a Unix timestamp
date_timezone_get() Returns the time zone of the given DateTime object
date_timezone_set() Sets the time zone for the DateTime object
date() Formats a local date and time
getdate() Returns date/time information of a timestamp or the current local date/time
gettimeofday() Returns the current time
gmdate() Formats a GMT/UTC date and time
gmmktime() Returns the Unix timestamp for a GMT date
gmstrftime() Formats a GMT/UTC date and time according to locale settings
idate() Formats a local time/date as integer
localtime() Returns the local time
microtime() Returns the current Unix timestamp with microseconds
mktime() Returns the Unix timestamp for a date
strftime() Formats a local time and/or date according to locale settings
strptime() Parses a time/date generated with strftime()
strtotime() Parses an English textual datetime into a Unix timestamp
time() Returns the current time as a Unix timestamp
timezone_abbreviations_list() Returns an associative array containing dst, offset, and the timezone name
timezone_identifiers_list() Returns an indexed array with all timezone identifiers
timezone_location_get() Returns location information for a specified timezone
timezone_name_from_ abbr() Returns the timezone name from abbreviation
timezone_name_get() Returns the name of the timezone
timezone_offset_get() Returns the timezone offset from GMT
timezone_open() Creates new DateTimeZone object
timezone_transitions_get() Returns all transitions for the timezone
timezone_version_get() Returns the version of the timezonedb

PHP预定义日期/时间常数

持续的 描述
date_atom. Atom(例:2019-01-18T14:13:03 + 00:00)
date_cookie. HTTP cookie(例如:Fri,2019年1月18日18:13:03 UTC)
date_iso8601. ISO-8601(例如:2019-01-18T14:13:03 + 0000)
date_rfc822. RFC 822(例如:2019年1月18日星期五18:13:03 +0000)
date_rfc850. RFC 850(例如:星期五,18-1月19日14:13:03 UTC)
date_rfc1036. RFC 1036(例如:星期五,18-Jan-19 14:13:03 +0000)
date_rfc1123. RFC 1123(例如:2019年1月18日星期五18:13:03 +0000)
date_rfc2822 RFC 2822(例如:2019年1月18日星期五18:13:03 +0000)
date_rfc3339. 与date_atom相同(PHP 5.1.3)
date_rfc3339_extended RFC3339扩展格式(因为PHP 7.0.0)(例如: 2019-01-18T16:34:01.000 + 00:00)
date_rss. RSS(免费,2019年1月18日14:13:03 +0000)
date_w3c. 万维网联盟(例如:2019-01-18T14:13:03 + 00:00)
sunfuncs_ret_timestamp。 时间戳(自PHP 5.1.2)
sunfuncs_ret_string。 小时:分钟(例如:09:41)(因为PHP 5.1.2)
sunfuncs_ret_double. 小时作为浮点数(例如:9.75)(因为PHP 5.1.2)

 

 

  
  

评论区

{{item['qq_nickname']}}
()
回复
回复
    相似文章