DateTime object is blank

Posted by user522962 on Stack Overflow See other posts from Stack Overflow or by user522962
Published on 2011-01-16T21:54:16Z Indexed on 2011/01/16 22:53 UTC
Read the original article Hit count: 157

Filed under:

I am trying to convert a date to a DateTime Object. My code works fine on my localhost (php version 5.3) but returns a blank DateTime object on my remote server (php version 5.2.14). Am I missing something really obvious?

<?php
   $d = '2010-01-01';
   $n = new DateTime ( $d );
   print_r($n);   
?>

// result on localhost:

 DateTime Object ( [date] => 2010-01-01 00:00:00 [timezone_type] => 3 [timezone] => UTC )

// result on remotehost:

 DateTime Object ( ) // is blank

© Stack Overflow or respective owner

Related posts about php