views:

661

answers:

1
+2  A: 

The last line would have to be translated to

echo '<h3>' . $reqDate->format('U') . '</h3>';

in order to work with PHP 5.2. Other that that, it looks fine.

Edit: You could subclass DateTime to provide a forwards compatible solution:

class MyDateTime extends DateTime {
    public function getTimestamp() {
         return method_exists('DateTime', 'getTimestamp') ? 
             parent::getTimestamp() : $this->format('U');
    }
}
Øystein Riiser Gundersen
Oh perfect, I didn't realise I could use format to get the timestamp! Thank you.
aland