setTimezone($timezone); // Return the converted time return $date->format('Y-m-d H:i:s'); } /** * Get the local format of a given time. * * @param string $created_time The time to format. * @param string $separator The separator between date and time. * @return string The formatted time in the local WordPress timezone. */ public static function getLocalFormat( $created_time, $separator = ' ' ){ // Get the date format $date_format = get_option('date_format'); $date_format = empty($date_format) ? 'Y/m/d' : $date_format; // Get the time format $time_format = get_option('time_format'); $time_format = empty($time_format) ? 'g:i a' : $time_format; $full_date = mysql2date( $date_format . $separator . $time_format, $created_time ) ; return $full_date; } }