filter date and time to differents time zone

Found this. Modified a bit to offset in hours, and it sorta works, not totally though… does weird stuff with the time if it’s close to midnight.

Original here

function cc_time_machine( $formatted, $format ) {
    $offset = -3; // Offset in hours, can be negative.
    if ( $offset ) {
        global $post;
        $timestamp = get_post_time( 'U', true, $post ); // UTC timestamp with GMT offset included.
        $adjusted = $timestamp + ( (int) $offset * HOUR_IN_SECONDS );
        return date( $format, $adjusted );
    }
    // If option doesn't exist, then just return it unmodified.
    return $formatted;
}
add_filter( 'get_the_time', 'cc_time_machine', 10, 2 );