Troubles with DateTime and PHP 5.2

Posted by Nate Wagar on Stack Overflow See other posts from Stack Overflow or by Nate Wagar
Published on 2010-05-24T13:27:10Z Indexed on 2010/05/24 13:31 UTC
Read the original article Hit count: 251

Filed under:
|
|

I'm attempting to use the PHP DateTime class on a server with PHP 5.2.6, with a test server running PHP 5.3. Here is the code:

<?php
try {
$dt = new DateTime('2009-10-08');
$dt->setDate(2009,10,8);
print_r($dt);
}catch (Exception $e) {
    echo $e->getMessage();
}

On the test server, things work flawlessly, this is what prints:

DateTime Object ( [date] => 2009-10-08 00:00:00 [timezone_type] => 3 [timezone] => America/New_York )

On the server I need to use it on, however, this is what prints:

DateTime Object ( )

Removing the setDate makes no difference whatsoever.

Any ideas why this might be happening?

Thanks!

© Stack Overflow or respective owner

Related posts about php

Related posts about php5