PHP Date & Time Functions
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.
Here is the list of php date and time functions
Method | Description |
---|---|
checkdate |
It is used for the validation of Gregorian date. |
date_add |
alias of It is used to add a given number of days, months, years, hours, minutes, and seconds to a date. |
date_create_from_format |
alias of It returns a new DateTime object formatted according to the specified format. |
date_create |
alias of It returns a new DateTime object. |
date_date_set |
alias of It is used to set a new date. |
date_default_timezone_get |
It returns the default timezone used by all date/time functions. |
date_default_timezone_set |
It sets the default timezone used by all date/time functions |
date_diff |
alias of |
date_format |
alias of It returns a date formatted according to the specified format. |
date_get_last_errors |
alias of It returns the warnings/errors |
date_interval_create_from_date_string |
alias of It sets up a DateInterval from the relative parts of the string. |
date_interval_format |
alias of It is used to format the interval. |
date_isodate_set |
alias of It returns a date according to the ISO 8601 standard using weeks and day offsets |
date_modify |
alias of It modifies the timestamp. |
date_offset_get |
alias of It returns the timezone offset. |
date_parse_from_format |
It returns information about given date formatted according to the specified format |
date_parse |
It returns an associative array having information about a given date. |
date_sub |
alias of It is used to subtract a given number of days, months, years, hours, minutes, and seconds from a date. |
date_sun_info |
It returns an array containing information about sunset/sunrise and twilight begin/end |
date_sunrise |
It returns time of sunset for a given day and location. |
date_sunset |
It returns time of sunset for a given day and location. |
date_time_set |
alias of It is used to set the time. |
date_timestamp_get |
alias of It returns the Unix timestamp |
date_timestamp_set |
alias of It helps to sets the date and time based upon a Unix timestamp. |
date_timezone_get |
alias of It returns the timezone of the DateTime object. |
date_timezone_set |
alias of It is used to set the timezone for DateTime Object. |
date |
It 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 |
It returns the current time. |
gmdate |
It formats a GMT/UTC date/time |
gmmktime |
It returns the Unix timestamp for a GMT date. |
gmstrftime |
It formats GMT/UTC date and time as per locale settings |
idate |
It formats a locate time/date as integer. |
localtime |
It returns the local time |
microtime |
It returns current unix timestamp with microseconds. |
mktime |
It returns the Unix timestamp for a date |
strftime |
It formats a local time/date as per locale settings. |
strptime |
It parses a time/date generated with |
strtotime |
Parsing of any English datetime description into Unix timestamp (the number of seconds since January 1 1970 00:00:00 GMT). It carefully handle dates in the m/d/y or d-m-y formats.
|
time |
It returns the current time in number of seconds since the Unix Epoch (January 1 1970 00:00:00 GMT) |
timezone_abbreviations_list |
It returns an associative array with DST, offset and timezone name. Alias of |
timezone_identifiers_list |
It returns an array having all timezone identifiers. Alias of |
timezone_location_get |
It returns the information about location of the given timezone. |
timezone_name_from_ abbr |
It returns the timezone name from abbreviation |
timezone_name_get |
It returns the name of timezone. Alias of |
timezone_offset_get |
It returns the timezone offset from GMT. Alias of |
timezone_open |
It creates a new DateTimeZone Object. Alias of |
timezone_transitions_get |
It returns all the transitions of timezone. Alias of |
timezone_version_get |
It returns the version of timezonedb. |