Sometimes you want to check if a string represents a valid timezone. Using PHP versions greater than 5.2, timezone_identifiers_list() could be a solution.
Take a look in the following function:
<?php
/**
* Check if a string is a valid timezone
*
* timezone_identifiers_list() requires PHP >= 5.2
*
* @param string $timezone
* @return bool
*/
function isValidTimezone($timezone) {
return in_array($timezone, timezone_identifiers_list());
}
?>
References
From PHP manual
- timezone_identifiers_list() (PHP 5 >= 5.2.0)
Entrepreneur | Full-stack developer | Founder of MediSign Ltd. I have over 15 years of professional experience designing and developing web applications. I am also very experienced in managing (web) projects.