Ticket #20942: gmt-date-matches-refresh.diff
File gmt-date-matches-refresh.diff, 835 bytes (added by , 13 years ago) |
---|
-
wp-includes/formatting.php
1892 1892 */ 1893 1893 function get_gmt_from_date($string, $format = 'Y-m-d H:i:s') { 1894 1894 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); 1895 1896 if ( ! $matches ) 1897 return date( $format, 0 ); 1898 1895 1899 $tz = get_option('timezone_string'); 1896 1900 if ( $tz ) { 1897 1901 date_default_timezone_set( $tz ); 1898 $datetime = new DateTime( $string ); 1902 $datetime = date_create( $string ); 1903 if ( ! $datetime ) 1904 return date( $format, 0 ); 1905 1899 1906 $datetime->setTimezone( new DateTimeZone('UTC') ); 1900 1907 $offset = $datetime->getOffset(); 1901 1908 $datetime->modify( '+' . $offset / 3600 . ' hours');