PHP

PHP Menu

PHP

Built-in Date Functions

Here is an alphabetical list of PHP’s built-in Date functions.

Function Description
checkdate() Validates a Gregorian date
date_add() Adds an amount of days, months, years, hours, minutes and seconds to a date
date_create_from_format() Returns a new DateTime object formatted according to the specified format
date_create() Returns new DateTime object
date_date_set() Sets a new date
date_default_timezone_get() Returns the default timezone used by all date/time functions in a script
date_default_timezone_set() Sets the default timezone used by all date/time functions in a script
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 and errors found while parsing a date/time 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() Set a date according to the ISO 8601 standard
date_modify() Modifies the timestamp
date_offset_get() Returns the timezone offset
date_parse_from_format() Returns an associative array with detailed info about given date formatted according to the specified format
date_parse() Returns associative array with detailed info about a specified date
date_sub() Subtracts an amount of days, months, years, hours, minutes and seconds from a date
date_sun_info() Returns an array with information about sunset/sunrise and twilight begin/end for a specified day and location
date_sunrise() Returns time of sunrise for a given day and location
date_sunset() Returns time of sunset for a given day and location
date_time_set() Sets the time
date_timestamp_get() Returns the Unix timestamp representing the date
date_timestamp_set() Sets the date and time based on an Unix timestamp
date_timezone_get() Return time zone relative to given DateTime
date_timezone_set() Sets the time zone for the DateTime object
date() Formats a local date and time
getdate() Returns date/time information of the timestamp or the current local date/time
gettimeofday() Returns the current time
gmdate() Formats a GMT/UTC date and time
gmmktime() Get 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() Return the current Unix timestamp with microseconds
mktime() Returns the Unix timestamp for a date
strftime() Formats a local time/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 associative array containing dst, offset and the timezone name
timezone_identifiers_list() Returns an indexed array containing all defined timezone identifiers
timezone_location_get() Returns the 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 current version of the timezonedb

Introduction

PHP Basics

PHP Advance

PHP OOP

PHP Functions and Methods