Reference › Functions get_date_from_gmt ( string $date_string , string $format = 'Y-m-d H:i:s' ): string
Since 1.2.0
Source wp-includes/formatting.php:3693Description Parameters Return Uses Used by Source History Given a date in UTC or GMT timezone, returns that date in the timezone of the site.
Description Requires a date in the Y-m-d H:i:s format.Default return format of 'Y-m-d H:i:s' can be overridden using the $format parameter.
Parameters
$date_stringstring The date to be converted, in UTC or GMT timezone.
$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 the site's timezone. Uses · 2 wp_timezone() Retrieves the timezone of the site as a `DateTimeZone` object. DateTimeZone::__construct() Source View on Trac ↗ View on GitHub ↗
3693 function get_date_from_gmt ( $date_string , $format = 'Y-m-d H:i:s' ) { 3694 $datetime = date_create ( $date_string , new DateTimeZone ( 'UTC' ) ) ; 3695 3696 if ( false === $datetime ) { 3697 return gmdate ( $format , 0 ) ; 3698 } 3699 3700 return $datetime -> setTimezone ( wp_timezone ( ) ) -> format ( $format ) ; 3701 } 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.