Skip to content

Instantly share code, notes, and snippets.

@sscovil
Created December 9, 2013 13:09
Show Gist options
  • Save sscovil/7872043 to your computer and use it in GitHub Desktop.
Save sscovil/7872043 to your computer and use it in GitHub Desktop.
<?php
/**
* Is Valid Timezone ID
*
* @param string $timezone_id Timezone ID to validate.
*
* @return bool True if timezone ID is valid; otherwise false.
*/
function is_valid_timezone_id( $timezone_id ){
$valid = array();
$tza = timezone_abbreviations_list();
foreach ( $tza as $zone )
foreach ( $zone as $item )
$valid[$item['timezone_id']] = true;
unset( $valid[''] );
return !!$valid[$timezone_id];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment