mirror of
https://github.com/WordPress/WordPress.git
synced 2025-01-05 16:08:12 +01:00
fixed and simplified get_date_from_gmt and get_gmt_from_date
git-svn-id: http://svn.automattic.com/wordpress/trunk@928 1a063a9b-81f0-0310-95a4-ce76da25c4cd
This commit is contained in:
parent
823986b932
commit
b4eb99a27f
@ -391,27 +391,22 @@ function wp_iso_descrambler($string) {
|
|||||||
|
|
||||||
// give it a date, it will give you the same date as GMT
|
// give it a date, it will give you the same date as GMT
|
||||||
function get_gmt_from_date($string) {
|
function get_gmt_from_date($string) {
|
||||||
|
// note: this only substracts $time_difference from the given date
|
||||||
$time_difference = get_settings('time_difference');
|
$time_difference = get_settings('time_difference');
|
||||||
// $string must be of the form 'yyyy-mm-dd hh:mm:ss'
|
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);
|
||||||
if ($string != gmdate('Y-m-d H:i:s', strtotime($string))) {
|
$string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
|
||||||
$string_time = gmmktime(substr($string,11,13), substr($string,14,16), substr($string,17,19), substr($string,5,7), substr($string,8,10), substr($string,0,4));
|
$string_gmt = gmdate('Y-m-d H:i:s', $string_time - $time_difference*3600);
|
||||||
$gmt_time = $string_time - $time_difference*3600;
|
return $string_gmt;
|
||||||
return date('Y-m-d H:i:s', $gmt_time);
|
|
||||||
} else {
|
|
||||||
return $string;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// give it a GMT date, it will give you the same date with $time_difference added
|
// give it a GMT date, it will give you the same date with $time_difference added
|
||||||
function get_date_from_gmt($string) {
|
function get_date_from_gmt($string) {
|
||||||
|
// note: this only adds $time_difference to the given date
|
||||||
$time_difference = get_settings('time_difference');
|
$time_difference = get_settings('time_difference');
|
||||||
// $string must be of the form 'yyyy-mm-dd hh:mm:ss'
|
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);
|
||||||
if ($string == gmdate('Y-m-d H:i:s', gmmktime(substr($string,11,13), substr($string,14,16), substr($string,17,19), substr($string,5,7), substr($string,8,10), substr($string,0,4)))) {
|
$string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
|
||||||
$local_time = strtotime($string) + $time_difference*3600;
|
$string_localtime = gmdate('Y-m-d H:i:s', $string_time + $time_difference*3600);
|
||||||
return date('Y-m-d H:i:s', $local_time);
|
return $string_localtime;
|
||||||
} else {
|
|
||||||
return $string;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
?>
|
?>
|
Loading…
Reference in New Issue
Block a user