May 11, 2021 PHP
This section provides an introduction to the PHP5 Date/Time function, which is detailed below!
The Date/Time function allows you to get the date and time from the server on which the PHP script runs. You can use the Date/Time function to format dates and times in different ways.
Note: These functions depend on the local settings of the server. When using these functions, remember to consider daylight saving time and leap years.
The PHP Date/Time function is part of the PHP core. These functions can be used without installation.
The behavior of the Date/Time function is affected .ini settings in php:
name | describe | default | PHP version |
---|---|---|---|
date.timezone | Specify the default time zone (all DATE / TIME functions use this option) | "" | PHP 5.1 |
date.default_latitude | Specify the default latitude (DATE_SUNRISE () and Date_SunSet () Use this option) | "31.7667" | PHP 5.0 |
date.default_longitude | Specify the default longitude (Date_Sunrise () and Date_SunSet () Use this option) | "35.2333" | PHP 5.0 |
date.sunrise_zenith | Specify the default sunrise heaven (Date_Sunrise () and Date_SunSet () Use this option) | "90.83" | PHP 5.0 |
date.sunset_zenith | Specify the default sunset heaven (Date_Sunrise () and Date_SunSet () Use this option) | "90.83" | PHP 5.0 |
function | describe |
---|---|
checkdate() | Verify the Date of Gregory. |
date_add() | Add a day, month, year, time, minute, and second to a date. |
date_create_from_format() | Returns a new DateTime object that formats based on 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 and is used by all DATE / TIME functions. |
date_default_timezone_set() | Set the default time zone and is used by all DATE / TIME functions. |
date_diff() | Returns the difference between the two days. |
date_format() | Returns the date based on the specified format. |
date_get_last_errors() | Returns a warning / error in the date string. |
date_interval_create_from_date_string() | Create a DateInterval from the relevant part of the string. |
date_interval_format() | Format time interval. |
date_isodate_set() | Set the ISO date. |
date_modify() | Modify the timestamp. |
date_offset_get() | Returns the time zone offset. |
date_parse_from_format() | Returns an associated array with a specified date in accordance with the specified format. |
date_parse() | Returns an associated array with detailed information with a specified date. |
date_sub() | Subtract date, month, year, time, minute, and seconds from the specified date. |
date_sun_info() | Returns an array containing information about the sunset / sunset and dusk start / dusk. |
date_sunrise() | Returns the sunrise time for the specified date and place. |
date_sunset() | Returns the sunset time of the specified date and place. |
date_time_set() | Set time. |
date_timestamp_get() | Returns the UNIX timestamp. |
date_timestamp_set() | Set the date and time based on UNIX timestamp. |
date_timezone_get() | Returns the time zone for a given DateTime object. |
date_timezone_set() | Set the time zone of the DateTime object. |
date() | Format the local date and time. |
getdate() | Returns a timestamp or the date / time information of the current local date / time. |
gettimeofday() | Returns the current time. |
gmdate() | Format GMT / UTC date and time. |
gmmktime() | Returns the UNIX timestamp of the GMT date. |
gmstrftime() | Format the GMT / UTC date and time according to region settings. |
idate() | Format local time / date is integer. |
localtime() | Returns local time. |
microtime() | Returns the number of microseconds of the current UNIX timestamp. |
mktime() | Returns a Date UNIX timestamp. |
strftime() | Format local time / date according to region settings. |
strptime() | Analysis The time / date generated by strftime (). |
strtotime() | Work with the date or time description of any English text to UNIX timestamps. |
time() | Returns the current time UNIX timestamp. |
timezone_abbreviations_list() | Returns an associated array containing the daylight saving time, offset, and time zone name. |
timezone_identifiers_list() | Returns a numerical array with all time zone identifiers. |
timezone_location_get() | Returns the location information of the specified time zone. |
timezone_name_from_ abbr() | Returns the time zone name based on the time zone abbreviation. |
timezone_name_get() | Returns the name of the time zone. |
timezone_offset_get() | Returns the time zone offset relative to the GMT. |
timezone_open() | Create a new DateTimezone object. |
timezone_transitions_get() | Returns all conversion of the time zone. |
timezone_version_get() | Returns the version of the time zone database. |
constant | describe |
---|---|
DATE_ATOM | Atom (for example: 2005-08-15t16: 13: 03 + 0000) |
DATE_COOKIE | HTTP cookies (for example: sun, 14 aug 2005 16:13:03 UTC) |
DATE_ISO8601 | ISO-8601 (eg, 2005-08-14T16: 13: 03 + 0000) |
DATE_RFC822 | RFC 822 (for example: sun, 14 aug 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, 14 aug 2005 16:13:03 UTC) |
DATE_RFC2822 | RFC 2822 (for example: Sun, 14 AUG 2005 16:13:03 +0000) |
DATE_RSS | RSS (for example: sun, 14 aug 2005 16:13:03 UTC) |
DATE_W3C | World Wide Web Alliance (for example: 2005-08-14T16: 13: 03 + 0000) |
That's all about the Date/Time function in PHP5!