1. Date and Time Formatting
These functions are used to format dates and times.
date()
— Formats a local date and time according to a specified format.date_create()
— Creates a newDateTime
object.date_format()
— Formats aDateTime
object.strftime()
— Formats a local time/date according to the specified format (locale-dependent).gmdate()
— Formats a GMT date and time.time()
— Returns the current Unix timestamp (seconds since the Unix Epoch).getdate()
— Returns an associative array containing date information.localtime()
— Returns an associative array containing local time information.microtime()
— Returns the current Unix timestamp with microseconds.date_create_from_format()
— Creates aDateTime
object from a specific format.date_parse()
— Parses a date and time into an array.
2. Date and Time Parsing and Conversion
These functions are used to parse strings into date/time objects or to convert them into other formats.
strtotime()
— Parses an English textual datetime description into a Unix timestamp.date_parse_from_format()
— Parses a date/time string into an associative array based on a specific format.date_create_from_format()
— Creates aDateTime
object from a string using a specified format.getdate()
— Retrieves date information from a timestamp.
3. Time Zone Functions
These functions help manage and manipulate time zones.
date_default_timezone_set()
— Sets the default time zone for all date/time functions.date_default_timezone_get()
— Gets the default time zone.timezone_open()
— Opens aDateTimeZone
object.timezone_identifiers_list()
— Returns a list of all supported time zones.timezone_name_get()
— Gets the name of the time zone.timezone_offset_get()
— Gets the offset from UTC for a time zone.timezone_transitions_get()
— Returns an array of time zone transitions.
4. Date and Time Arithmetic
These functions are used to add or subtract time and calculate intervals.
strtotime()
— Parses a relative time string (e.g.,+1 day
,-1 week
) and returns a Unix timestamp.date_add()
— Adds a time interval to aDateTime
object.date_sub()
— Subtracts a time interval from aDateTime
object.diff()
— Returns the difference between twoDateTime
objects as aDateInterval
object.date_interval_create_from_date_string()
— Creates aDateInterval
object from a date string.date_modify()
— Modifies theDateTime
object by adding or subtracting time.
5. Time and Date Comparisons
These functions are used to compare date and time values.
date_diff()
— Calculates the difference between twoDateTime
objects.date_timestamp_get()
— Gets the Unix timestamp from aDateTime
object.date_timestamp_set()
— Sets the Unix timestamp for aDateTime
object.time()
— Returns the current Unix timestamp.
6. Date and Time Information
These functions are used to retrieve specific parts or elements of a date/time.
date("Y-m-d H:i:s")
— Formats the current date and time.gettimeofday()
— Returns current Unix timestamp along with microseconds.localtime()
— Returns an associative array containing local time information.gmdate()
— Formats a GMT date and time.getdate()
— Returns an array of date information.
7. Date and Time Validation
These functions are used to check the validity of a given date or time.
checkdate()
— Validates a Gregorian date (month, day, year).is_numeric()
— Checks if a value is a valid numeric value for timestamps.date_create_from_format()
— Parses a date string into aDateTime
object, useful for validation.
8. Date and Time Intervals
These functions deal with intervals between dates and creating intervals.
date_interval_create_from_date_string()
— Creates aDateInterval
object from a string (e.g.,P1Y2M10DT2H30M
).date_add()
— Adds aDateInterval
object to aDateTime
object.date_sub()
— Subtracts aDateInterval
object from aDateTime
object.date_diff()
— Calculates the difference between twoDateTime
objects.date_interval_format()
— Formats aDateInterval
object as a string.
9. Miscellaneous Functions
These functions provide additional utility when working with date and time.
time()
— Returns the current Unix timestamp.microtime()
— Returns the current Unix timestamp with microseconds.date_default_timezone_set()
— Sets the default time zone for all date/time functions.date_default_timezone_get()
— Gets the default time zone.strtotime()
— Converts an English textual datetime description into a Unix timestamp.
No hay comentarios:
Publicar un comentario