Changeset 928
- Timestamp:
- 02/23/2004 04:09:27 PM (22 years ago)
- File:
-
- 1 edited
-
trunk/wp-includes/functions-formatting.php (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/wp-includes/functions-formatting.php
r918 r928 392 392 // give it a date, it will give you the same date as GMT 393 393 function get_gmt_from_date($string) { 394 // note: this only substracts $time_difference from the given date 394 395 $time_difference = get_settings('time_difference'); 395 // $string must be of the form 'yyyy-mm-dd hh:mm:ss' 396 if ($string != gmdate('Y-m-d H:i:s', strtotime($string))) { 397 $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)); 398 $gmt_time = $string_time - $time_difference*3600; 399 return date('Y-m-d H:i:s', $gmt_time); 400 } else { 401 return $string; 402 } 396 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); 397 $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); 398 $string_gmt = gmdate('Y-m-d H:i:s', $string_time - $time_difference*3600); 399 return $string_gmt; 403 400 } 404 401 405 402 // give it a GMT date, it will give you the same date with $time_difference added 406 403 function get_date_from_gmt($string) { 404 // note: this only adds $time_difference to the given date 407 405 $time_difference = get_settings('time_difference'); 408 // $string must be of the form 'yyyy-mm-dd hh:mm:ss' 409 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)))) { 410 $local_time = strtotime($string) + $time_difference*3600; 411 return date('Y-m-d H:i:s', $local_time); 412 } else { 413 return $string; 414 } 406 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); 407 $string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]); 408 $string_localtime = gmdate('Y-m-d H:i:s', $string_time + $time_difference*3600); 409 return $string_localtime; 415 410 } 416 411
Note: See TracChangeset
for help on using the changeset viewer.