|Timezone in PHP||#1|
PHP seems to use a rather annoying method for setting the evnironment timezone, using region names rather than the GMT offset. This makes having a timezone dropdown a huge pain, because it either has to be huge to accommodate all possible PHP timezone values, or I have to find a way to convert a GMT offset to a valid value to pass to PHP.
So, given a GMT offset, how might I set the timezone in PHP? For example, how might I convert the GMT offset value of "-8.0" to a value that I could pass to
posted date: 2009-04-13 10:26:00
|Re: Timezone in PHP||#3|
You will need to maintain a database with the daylight saving data of various locations, that(s why it is better to store a location.
posted date: 2009-04-13 10:33:00
|Re: Timezone in PHP||#4|
How does PHP know the conversions (such as with DateTimeZone::getOffset) from one region to another if regional timekeeping conventions are always changing?
posted date: 2009-04-13 10:54:00
|Re: Timezone in PHP||#5|
I imagine those come in PHP updates. You are keeping your PHP patched, right? :-)
posted date: 2009-04-13 10:55:00
|Re: Timezone in PHP||#6|
If you are using PHP >= 5.2, you can use the built-in DateTimeZone class method, listAbbreviations.
var_dump( DateTimeZone::listAbbreviations() );
posted date: 2009-04-13 11:39:00
|Re: Timezone in PHP||#7|
Do they still release patches for PHP3? =P
posted date: 2009-04-15 00:45:00
|Re: Timezone in PHP||#8|
I think this provides in-between PHP version updates to the timezone database pecl.php.net/package/timezonedb
posted date: 2012-11-04 20:43:00
|Re: Timezone in PHP||#9|
You can also try to use PHP library Dater for working with datetime in different timezones and formats - https://github.com/barbushin/dater
posted date: 2013-12-27 04:40:00
|select page: « 1 »|