Date and time functions in PHP help in retrieving date and time from the server and then format the result by various methods given in PHP.The output of these functions depends upon the locale settings of the server. Date and time functions are described below with suitable examples.

checkdate()used for the validation of Gregorian date.
date_add()alias of DateTime::add() used to add a given number of days, months, years, hours, minutes, and seconds to a date.
date_create_from_format()alias of DateTime::createFromFormat returns a new DateTime object formatted according to the specified format.
date_create()alias of DateTime::__construct() returns a new DateTime object.
date_date_set()alias of DateTime::setDate used to set 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()alias of DateTime::diff
date_format()alias of DateTime::format returns a date formatted according to the specified format.
date_get_last_errors()alias of DateTime::getLastErrors() returns the warnings/errors
date_interval_create_from_date_string()alias of DateInterval::createFromDateString() sets up a DateInterval from the relative parts of the string.
date_interval_format()alias of DateInterval::format() used to format the interval.
date_isodate_set()alias of DateTime::setISODate() returns a date according to the ISO 8601 standard using weeks and day offsets
date_modify()alias of DateTime::modify modifies the timestamp.
date_offset_get()alias of DateTime::getOffset returns the timezone offset.
date_parse_from_format()returns information about given date formatted according to the specified format
date_parse()returns an associative array having information about a given date.
date_sub()alias of DateTime::sub()
It is used to subtract a given number of days, months, years, hours, minutes, and seconds from a date.
date_sun_info()returns an array containing information about sunset/sunrise and twilight begin/end
date_sunrise()returns time of sunset for a given day and location.
date_sunset()returns time of sunset for a given day and location.
date_time_set()alias of DateTime::setTime
used to set the time.
date_timestamp_get()alias of DateTime::getTimestamp returns the Unix timestamp
date_timestamp_set()alias of DateTime::setTimestamp sets the date and time based upon a Unix timestamp.
date_timezone_get()alias of DateTime::getTimezone() returns the timezone of the DateTime object.
date_timezone_set()alias of DateTime::setTimezone() used to set the timezone for DateTime Object.
date()formats a local date/time and returns a string
getdate()Returns an associative array having date information of the timestamp or the current local time if timestamp is omitted or NULL.
gettimeofday()returns the current time.
gmdate()formats a GMT/UTC date/time
gmmktime()returns the Unix timestamp for a GMT date
gmstrftime()formats GMT/UTC date and time as per locale settings
idate()formats a locate time/date as integer
localtime()returns the local time
microtime()returns current unix timestamp with microseconds.
mktime()returns the Unix timestamp for a date
strftime()formats a local time/date as per locale settings.
strptime()parses a time/date generated with strftime().
strtotime()Parsing of any English datetime description into Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT)
Carefully handle dates in the m/d/y or d-m-y formats.
– if the separator is a slash (/), then the American m/d/y is considered.
– If the separator is a dash (-) or a dot (.), then the European d-m-y format is considered.
– To avoid potential errors, use YYYY-MM-DD dates or date_create_from_format().
time()returns the current time in number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT)
timezone_abbreviations_list()Alias of DateTimeZone::listAbbreviations
returns an associative array with DST, offset and timezone name.
timezone_identifiers_list()Alias of DateTimeZone::listIdentifiers
returns an array having all timezone identifiers.
timezone_location_get()returns the information about location of the given timezone.
timezone_name_from_ abbr()returns the timezone name from abbreviation
timezone_name_get()Alias of DateTimeZone::getName
returns the name of timezone
timezone_offset_get()Alias of DateTimeZone::getOffset
returns the timezone offset from GMT.
timezone_open()Alias of DateTimeZone::__construct
creates a new DateTimeZone Object.
timezone_transitions_get()Alias of DateTimeZone::getTransitions and it can be called in two different ways.
returns all the transitions of timezone.
timezone_version_get()returns the version of timezonedb