I\'ll try to explain what\'s the problem here.
According to list of supported timezones from PHP manual, I can see all valid TZ identifiers in PHP.
My first
Why not use @ operator? This code works pretty well, and you don't change default timezone:
function isValidTimezoneId($timezoneId) {
@$tz=timezone_open($timezoneId);
return $tz!==FALSE;
}
If you don't want @, you can do:
function isValidTimezoneId($timezoneId) {
try{
new DateTimeZone($timezoneId);
}catch(Exception $e){
return FALSE;
}
return TRUE;
}