Definition:
function get_date_from_gmt($string, $format = 'Y-m-d H:i:s') {}
Converts a GMT date into the correct format for the blog.
Requires and returns in the Y-m-d H:i:s format. Simply adds the value of gmt_offset.Return format can be overridden using the $format parameter
Parameters
- string $string: The date to be converted.
- string $format: The format string for the returned date (default is Y-m-d H:i:s)
Return values
returns:Formatted date relative to the GMT offset.
Source code
function get_date_from_gmt($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);
$string_time = gmmktime($matches[4], $matches[5], $matches[6], $matches[2], $matches[3], $matches[1]);
$string_localtime = gmdate($format, $string_time + get_option('gmt_offset')*3600);
return $string_localtime;
}
1350

February 12, 2011 


No comments yet... Be the first to leave a reply!