PHP's being Ricky Retardo.
Written By alexsuraci on Jun. 27, 2008.
1 Comments
Report Note
+ Clip This
<?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.

Scrivs
Written Jun. 27, 2008 / Report /
Glad you found the bug before me. I'll have to remember to stay away from it.