Reference › Functions get_gmt_from_date ( string $date_string , string $format = 'Y-m-d H:i:s' ): string
Since 1.2.0
Source wp-includes/formatting.php:3671Description Parameters Return Uses Used by Source History Given a date in the timezone of the site, returns that date in UTC.
Description Requires and returns a date in the Y-m-d H:i:s format.Return format can be overridden using the $format parameter.
Parameters
$date_stringstring The date to be converted, in the timezone of the site.
$formatstring optional The format string for the returned date. Default 'Y-m-d H:i:s'.Default: 'Y-m-d H:i:s' Return
string Formatted version of the date, in UTC. Uses · 2 wp_timezone() Retrieves the timezone of the site as a `DateTimeZone` object. DateTimeZone::__construct() Source View on Trac ↗ View on GitHub ↗
3671 function get_gmt_from_date ( $date_string , $format = 'Y-m-d H:i:s' ) { 3672 $datetime = date_create ( $date_string , wp_timezone ( ) ) ; 3673 3674 if ( false === $datetime ) { 3675 return gmdate ( $format , 0 ) ; 3676 } 3677 3678 return $datetime -> setTimezone ( new DateTimeZone ( 'UTC' ) ) -> format ( $format ) ; 3679 } History Introduced in 1.2.0 . Unchanged from 6.7.7 through 7.1.0.
6.7.7 6.8.8 6.9.7 7.0.4 7.1.0 Signature, return type and hooks compared across 5 parsed releases.
About this page Parsed data Generated from the wordpress-develop 6.8.8 tag, from src/wp-includes/formatting.php, and regenerated for each WordPress release so it tracks the code rather than a snapshot of it. Corrections Something wrong on this page? Report it and it gets fixed in the next regeneration.