Hi, Is there any possibility to do a type casting into datetime in PHP? I need to convert a string datetime format into a valid datetime. I read in the manual that date_create() takes a string to create a date, but not sure if this is the correct way - anyone to advice? Thanks Ben
ngcoders, correct me if I am wrong, but is not the strtotime() function returning an integer form of the time? I need to return a valid DateTime from the string input. Ben
just forgot to mention, that I am using PHP 4, so it should be compatible with this version. So date_create() cannot be used. Can I then use this way? $dtValidDateTime; $szDate = '12/31/2007'; try { $dtValidDateTime = new DateTime($szDate); } catch(Exception $e) { //do something }
Tell your host to upgrade to PHP 5. The support for PHP 4 officially ended 4 days ago. Sooner or later your host will be forced to upgrade anyway. http://www.php.net/index.php#2007-07-13-1
well if it is up to me than I don't think too much about it, but unfortunately we need to support PHP 4, as some of our clients still use it. thanks nico_swd and all Ben