Remove PHP5 back compat code from get_gmt_from_date. Props technosailor. fixes #16920
git-svn-id: http://svn.automattic.com/wordpress/trunk@17920 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
5316894390
commit
58767691f4
|
@ -1588,8 +1588,7 @@ function _wp_iso_convert( $match ) {
|
||||||
*
|
*
|
||||||
* Requires and returns a date in the Y-m-d H:i:s format. Simply subtracts the
|
* Requires and returns a date in the Y-m-d H:i:s format. Simply subtracts the
|
||||||
* value of the 'gmt_offset' option. Return format can be overridden using the
|
* value of the 'gmt_offset' option. Return format can be overridden using the
|
||||||
* $format parameter. If PHP5 is supported, the function uses the DateTime and
|
* $format parameter.
|
||||||
* DateTimeZone objects to respect time zone differences in DST.
|
|
||||||
*
|
*
|
||||||
* @since 1.2.0
|
* @since 1.2.0
|
||||||
*
|
*
|
||||||
|
@ -1601,22 +1600,13 @@ function _wp_iso_convert( $match ) {
|
||||||
function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') {
|
function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') {
|
||||||
preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
|
preg_match('#([0-9]{1,4})-([0-9]{1,2})-([0-9]{1,2}) ([0-9]{1,2}):([0-9]{1,2}):([0-9]{1,2})#', $string, $matches);
|
||||||
$tz = get_option('timezone_string');
|
$tz = get_option('timezone_string');
|
||||||
if( class_exists('DateTime') && $tz ) {
|
date_default_timezone_set( $tz );
|
||||||
//PHP5
|
$datetime = new DateTime( $string );
|
||||||
date_default_timezone_set( $tz );
|
$datetime->setTimezone( new DateTimeZone('UTC') );
|
||||||
$datetime = new DateTime( $string );
|
$offset = $datetime->getOffset();
|
||||||
$datetime->setTimezone( new DateTimeZone('UTC') );
|
$datetime->modify( '+' . $offset / 3600 . ' hours');
|
||||||
$offset = $datetime->getOffset();
|
$string_gmt = gmdate($format, $datetime->format('U'));
|
||||||
$datetime->modify( '+' . $offset / 3600 . ' hours');
|
date_default_timezone_set('UTC');
|
||||||
$string_gmt = gmdate($format, $datetime->format('U'));
|
|
||||||
|
|
||||||
date_default_timezone_set('UTC');
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
//PHP4
|
|
||||||
$string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
|
|
||||||
$string_gmt = gmdate($format, $string_time - get_option('gmt_offset') * 3600);
|
|
||||||
}
|
|
||||||
return $string_gmt;
|
return $string_gmt;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue