PHP Date/time functions

Source: Internet
Author: User
Tags add days local time rfc sunrise time

Runtime Configuration

The behavior of the Date/time function is affected by the settings in php.ini:

name Description default PHP version
Date.timezone Specify the default time zone (all Date/time functions use this option) "" PHP 5.1
Date.default_latitude Specify Default latitude (Date_sunrise () and Date_sunset () Use this option) "31.7667" PHP 5.0
Date.default_longitude Specify default longitude (Date_sunrise () and Date_sunset () to use this option) "35.2333" PHP 5.0
Date.sunrise_zenith Specifies the default Sunrise Zenith (Date_sunrise () and Date_sunset () Use this option) "90.83" PHP 5.0
Date.sunset_zenith Specifies the default sunset Zenith (Date_sunrise () and Date_sunset () Use this option) "90.83" PHP 5.0

PHP 5 Date/time functions
function Description
Checkdate () Verify the Gregorian date.
Date_add () Add days, months, years, hours, minutes, and seconds to a date.
Date_create_from_format () Returns a new DateTime object that is formatted according to the specified format.
Date_create () Returns a new DateTime object.
Date_date_set () Set a new date.
Date_default_timezone_get () Returns the default time zone, which is used by all date/time functions.
Date_default_timezone_set () Set the default time zone, which is used by all date/time functions.
Date_diff () Returns the difference between two days.
Date_format () Returns the date formatted according to the specified format.
Date_get_last_errors () Returns a warning/error in a date string.
Date_interval_create_from_date_string () Create a dateinterval from the relevant part of the string.
Date_interval_format () Formats the time interval.
Date_isodate_set () Set the ISO date.
Date_modify () Modifies the timestamp.
Date_offset_get () Returns the time zone offset.
Date_parse_from_format () Returns an associative array with details of the specified date, according to the specified format.
Date_parse () Returns an associative array with detailed information for the specified date.
Date_sub () Subtracts days, months, years, hours, minutes, and seconds from a specified date.
Date_sun_info () Returns an array containing information about the sunrise/sunset and Dusk start/dusk end of the specified date and place.
Date_sunrise () Returns the sunrise time for the specified date and place.
Date_sunset () Returns the sunset time for the specified date and place.
Date_time_set () Set the time.
Date_timestamp_get () Returns the Unix timestamp.
Date_timestamp_set () Sets the date and time based on the Unix timestamp.
Date_timezone_get () Returns the time zone for a given DateTime object.
Date_timezone_set () Sets the time zone for a DateTime object.
Date () Formats the local date and time.
GETDATE () Returns the date/time information for a timestamp or the current local date/time.
Gettimeofday () Returns the current time.
Gmdate () Formats the GMT/UTC date and time.
Gmmktime () Returns the UNIX timestamp for the GMT date.
Gmstrftime () Formats the GMT/UTC date and time according to locale settings.
Idate () Formats the local time/date as an integer.
LocalTime () Returns the local time.
Microtime () Returns the number of microseconds for the current Unix timestamp.
Mktime () Returns a Unix timestamp for a date.
Strftime () Formats local time/date according to locale.
Strptime () Resolves the time/date generated by Strftime ().
Strtotime () Resolves the date or time description of any English text to a Unix timestamp.
Time () Returns the Unix timestamp for the current time.
Timezone_abbreviations_list () Returns an associative array that contains the daylight saving time, offset, and timezone name.
Timezone_identifiers_list () Returns an array of values with all time zone identifiers.
Timezone_location_get () Returns the location information for the specified time zone.
Timezone_name_from_ abbr () Returns the time zone name according to the time zone abbreviation.
Timezone_name_get () Returns the name of the time zone.
Timezone_offset_get () Returns the time zone offset relative to GMT.
Timezone_open () Creates a new Datetimezone object.
Timezone_transitions_get () Returns all transitions for the time zone.
Timezone_version_get () Returns the version of the time zone database.

PHP 5 pre-defined Date/time constants
Constants Description
Date_atom Atom (ex: 2005-08-15t16:13:03+0000)
Date_cookie HTTP Cookies (for example: Sun, 2005 16:13:03 UTC)
date_iso8601 ISO-8601 (ex: 2005-08-14t16:13:03+0000)
date_rfc822 RFC 822 (for example: Sun, 2005 16:13:03 UTC)
date_rfc850 RFC 850 (for example: Sunday, 14-aug-05 16:13:03 UTC)
date_rfc1036 RFC 1036 (for example: Sunday, 14-aug-05 16:13:03 UTC)
Date_rfc1123 RFC 1123 (for example: Sun, 2005 16:13:03 UTC)
date_rfc2822 RFC 2822 (for example: Sun, 2005 16:13:03 +0000)
Date_rss RSS (ex: Sun, 2005 16:13:03 UTC)
date_w3c World Wide Web Consortium (ex: 2005-08-14t16:13:03+0000)

PHP date/time functions

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.