Quantcast
Channel: How to check is timezone identifier valid from code? - Stack Overflow
Browsing all 9 articles
Browse latest View live

Answer by Will Voelcker for How to check is timezone identifier valid from code?

Just an addendum to Cal's excellent answer. I think the following might be even faster...function isValidTimezoneID($tzid) { if (empty($tzid)) { return false; } foreach (timezone_abbreviations_list()...

View Article



Answer by user2595120 for How to check is timezone identifier valid from code?

In case of php<5.3, how about this? public static function is_valid_timezone($timezone){ $now_timezone = @date_default_timezone_get(); $result = @date_default_timezone_set($timezone); if(...

View Article

Answer by gaRex for How to check is timezone identifier valid from code?

See in PHP sources on php_date.c and timezonemap.h that`s why I can say this is always in 101.111111% static info (but per php build).If you want to get it dynamically, use timezone_abbreviations_list...

View Article

Answer by sanmai for How to check is timezone identifier valid from code?

If you're on Linux most if not all information on timezones there stored at /usr/share/zoneinfo/. You can walk over them using is_file() and related functions. You can also parse the former files with...

View Article

Answer by Mel for How to check is timezone identifier valid from code?

I would research what changes the perfect array and use a basic caching mechanism (like store the array in a file, that you include and update when needed). You're currently optimizing building an...

View Article


Answer by Cal for How to check is timezone identifier valid from code?

You solution works fine, so if it's speed you're looking for I would look more closely at what you're doing with your arrays. I've timed a few thousand trials to get reasonable average times, and these...

View Article

Answer by Anomie for How to check is timezone identifier valid from code?

When I tried this on a Linux system running 5.3.6, your Example #2 gave me 411 zones and Example #3 gave 496. The following slight modification to Example #2 gives me 591:$zoneList =...

View Article

Answer by hectorct for How to check is timezone identifier valid from code?

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...

View Article


How to check is timezone identifier valid from code?

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 question is how to get that list from code but...

View Article

Browsing all 9 articles
Browse latest View live




Latest Images