get_gmt_from_date() – Returns a date in the GMT equivalent.
You appear to be a bot. Output may be restricted
Description
Given a date in the timezone of the site, returns that date in UTC.
Requires and returns a date in the Y-m-d H:i:s format. Return format can be overridden using the $format parameter.
Usage
$string = get_gmt_from_date( $date_string, $format );
Parameters
- $date_string
- ( string ) required – The date to be converted, in the timezone of the site.
- $format
- ( string ) optional default: Y-m-d H:i:s – The format string for the returned date. Default 'Y-m-d H:i:s'.
Returns
string Formatted version of the date, in UTC.
Source
File name: wordpress/wp-includes/formatting.php
Lines:
1 to 9 of 9
function get_gmt_from_date( $date_string, $format = 'Y-m-d H:i:s' ) { $datetime = date_create( $date_string, wp_timezone() ); if ( false === $datetime ) { return gmdate( $format, 0 ); } return $datetime->setTimezone( new DateTimeZone( 'UTC' ) )->format( $format ); }