I was having a dreadful time converting from the UTC time stamp stored in the WordPress database to the local time set in the admin panel. I ended up writing the following handy little function to convert the times easily. There may be a better way to do this, so if any of you know of an improved solution please let me know in the comments 🙂

/*
* Converts UTC time to local time as set in WordPress
* Processes data in the format "Y-m-d H:i:s" (same format as used in WordPress core)
*
* @author Ryan Hellyer <ryanhellyer@gmail.com>
*/
function convert_time( $time ) {
$timestamp = strtotime( $time ); // Converting time to Unix timestamp
$offset = get_option( 'gmt_offset' ) * 60 * 60; // Time offset in seconds
$local_timestamp = $timestamp + $offset;
$local_time = date_i18n( 'Y-m-d H:i:s', $local_timestamp );
return $local_time;
}

$time = '2012-08-03 12:33:07';
echo convert_time( $time );