Decaflon

Welcome to Decaflon! Where the geeks hang out: Signup or Login Here
Decaflon is proudly hosted by (mt) Media Temple.  We recommend them for your web hosting needs.
Clips: Popular Clips Upcoming Clips Notes: All Notes

<?php
$now = new DateTime("now", new DateTimeZone("Etc/GMT-4"));
echo $now->format("F jS, Y, g:i A");

Guess what that outputs?

If you thought "June 27th, 2008, 3:00 PM" (based on the time this note was posted), you'd be wrong. It actually outputs "June 27th, 2008, 11:00 PM". Why? I haven't the slightest idea. That's what time it is in GMT +4, not -4.

Any ideas why this is breaking so much? It seems PHP has arbitrarily switched the + and - GMT values.

At first I thought it might be basing the timezone's offset off of the server's local time, which is 3:00 PM (I live in GMT -4), but 3:00 PM - 4 hours = 11 AM, not 11 PM. Colour me confused.

Edit: Looks like PHP has deprecated GMT timezones in favour of using these. I guess that explains why they're broken, though it's still a colossal fuck-up.

Glad you found the bug before me. I'll have to remember to stay away from it.

Please Login To Leave A Comment

Decaflon Sponsors Get in touch if you want in.

Hot Notes (View all »)

 

Decaflon is part of the Chawlk Network of sites.

9 Great Places To Visit, Hang Out, & Meet New People

What's new and interesting at other Chawlk Network sites: