Interesting, yet quite simple to explain: As explained in the DateTime docs, the return value of
null until PHP 5.3.
In your code, you assign the result of
setTimezone to the
$utc variable. In PHP 5.3,
$utc is now the DateTime object again, in PHP 5.2 it's
null. In the following line, you try to call the
format method on
$utc, which of course must fail in PHP 5.2.