Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Evert Pot:
PHP 5.5.10 timezone handling changes
Mar 31, 2014 @ 17:29:27

Evert Pot has a new post sharing some of the changes in DateTime handling that he's updated in the latest release in the PHP 5.5.x series.

PHP 5.5.10 got released a few weeks ago, and among other things, it added some new functionality related to timezone handling. In short, [subtracting from UTC] now works. Normally this would not be recommended, as you really should specify timezones based on their geographical location. This information is not always available though, so it's a welcome new feature.

Other changes include the removal of the automatic translation from "UTC" to "GMT" as well as errors being thrown when one of the "odd" timezones are used (he provides the list). Additionally, an update around timezone "guessing" has been added and the fallback that was in place has been removed.

tagged: timezone change datetime utc gmt error names

Link: http://evertpot.com/php-5-5-10-timezone-changes/

Derick Rethans' Blog:
To GMT or not to GMT
Mar 01, 2012 @ 17:39:45

In this new post to his site, Derick Rethans shows an instance of "GMT being tricky" when it comes to "UTC" versus "GMT" output from PHP's DateTime object.

Earlier today, on twitter, @skoop asked: "dear #lazyweb, when I use DateTimeZone('GMT'), why does format('e') output UTC?" [...] As you can see [the example with a format of "e" on a DateTimeZone('GMT')] has UTC and not GMT as you might expect.

Derick mentions that sometimes, systems require "GMT" instead of "UTC" in the output they're given. To work around this issue, he shows how to add a "type 2" timezone to the DateTime object by including it when you initialize the object (code samples included). Using alternative methods, you can add these "type 2" timezones in three ways - an offset in the initial string, using the abbreviation (like "EST" or "PST") and specifying the long version of the timezone (like "America/Montreal").

tagged: datetime handling timezone gmt utc type2 initialize offset

Link:

Builder.com.au:
Get the correct time by converting between time zones with PHP and PEAR
Feb 23, 2007 @ 16:11:00

On the Builder.com.au website today, there's a quick new tutorial on grabbing the correct time for a user's "home" rather than the server's time.

PHP comes with an extensive catalog of date and time functions, all designed to let you easily retrieve temporal information, massage it into a format you require, and either use it in a calculation or display it to the user. However, if you'd like to do something more complicated, things get much, much hairier

To make things easier, they enlist the service of the PEAR Date package to help bridge the gap between the time zones faster. They give some of the basics of using the package before actually getting into the time zone conversion. The code is pretty straight-forward and they even include other simple tips like how to calculate the GMT offset and how to add and subtract timespans.

tagged: timezone pear date package difference gmt offset timezone pear date package difference gmt offset

Link:

Builder.com.au:
Get the correct time by converting between time zones with PHP and PEAR
Feb 23, 2007 @ 16:11:00

On the Builder.com.au website today, there's a quick new tutorial on grabbing the correct time for a user's "home" rather than the server's time.

PHP comes with an extensive catalog of date and time functions, all designed to let you easily retrieve temporal information, massage it into a format you require, and either use it in a calculation or display it to the user. However, if you'd like to do something more complicated, things get much, much hairier

To make things easier, they enlist the service of the PEAR Date package to help bridge the gap between the time zones faster. They give some of the basics of using the package before actually getting into the time zone conversion. The code is pretty straight-forward and they even include other simple tips like how to calculate the GMT offset and how to add and subtract timespans.

tagged: timezone pear date package difference gmt offset timezone pear date package difference gmt offset

Link:


Trending Topics: