You do not need original timezone, and then calculate offset between original and remote timezone; this can be accomplished without that. It doesn't matter in which timezone office is, office hours $office_hours
are always applied for local time. Said that, you can delete half of your calculation.
Use:
var_dump( isOfficeTime('America/New_York') ); # bool(false)
var_dump( isOfficeTime('Europe/Berlin') ); # bool(true)
var_dump( isOfficeTime('Australia/Sydney') ); # bool(false)
var_dump( isOfficeTime('Asia/Hong_Kong') ); # bool(false)
Function:
function isOfficeTime($tz) {
$office_hours = array(
'Monday' => array('9:00', '17:00'),
'Tuesday' => array('9:00', '17:00'),
'Wednesday' => array('9:00', '17:00'),
'Thursday' => array('9:00', '17:00'),
'Friday' => array('9:00', '17:00'),
'Saturday' => array('9:00', '12:00'),
'Sunday' => array('0:00', '0:00'),
);
$tz = new DateTimeZone($tz);
$now = new DateTime('now', $tz);
$start = new DateTime($office_hours[$now->format('l')][0], $tz);
$end = new DateTime($office_hours[$now->format('l')][1], $tz);
return $start != $end && $start <= $now && $now < $end;
}
Demo.