News Feed
Sections




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

Derick Rethans' Blog:
To GMT or not to GMT
March 01, 2012 @ 11: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").

0 comments voice your opinion now!
datetime handling timezone gmt utc type2 initialize offset


blog comments powered by Disqus

Similar Posts

Kenny Meyers' Blog: How CodeIgniter Works (Video from EECI 2010)

Builder.com.au: Get the correct time by converting between time zones with PHP and PEAR

SitePoint PHP Blog: Pimpin Harry’s pretty bluescreen

Joakim Nygard's Blog: Timezones in MySQL and PHP

Adam Trachtenberg's Blog: PHP Trivia Contest: DOM + Default Namespaces


Community Events





Don't see your event here?
Let us know!


voicesoftheelephpant release install package update security composer laravel series podcast framework language community version tool opinion interview symfony introduction library

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework