Uses
Uses | Description |
---|---|
wp-includes/functions.php: wp_timezone() | Retrieves the timezone from site settings as a |
Given an ISO 8601 (Ymd\TH:i:sO) date, returns a MySQL DateTime (Y-m-d H:i:s) format used by post_date[_gmt].
(string) (Required) Date and time in ISO 8601 format https://en.wikipedia.org/wiki/ISO_8601.
(string) (Optional) If set to 'gmt' returns the result in UTC.
Default value: 'user'
(string|bool) The date and time in MySQL DateTime format
File: wp-includes/formatting.php
function iso8601_to_datetime( $date_string, $timezone = 'user' ) { $timezone = strtolower( $timezone ); $wp_timezone = wp_timezone(); $datetime = date_create( $date_string, $wp_timezone ); // Timezone is ignored if input has one. if ( false === $datetime ) { return false; } if ( 'gmt' === $timezone ) { return $datetime->setTimezone( new DateTimeZone( 'UTC' ) )->format( 'Y-m-d H:i:s' ); } if ( 'user' === $timezone ) { return $datetime->setTimezone( $wp_timezone )->format( 'Y-m-d H:i:s' ); } return false; }
Version | Description |
---|---|
1.5.0 | Introduced. |
© 2003–2019 WordPress Foundation
Licensed under the GNU GPLv2+ License.
https://developer.wordpress.org/reference/functions/iso8601_to_datetime