Casting from parent class to child

From: Date: Wed, 06 Oct 2010 14:02:09 +0000
Subject: Casting from parent class to child
Groups: php.general 
Request: Send a blank email to php-general+get-308508@lists.php.net to get a copy of this message
Hi, I'm trying to extends the base class DateTime. parent::createFromFormat("H.i d.m.Y", $string); returns a DateTime and I want to convert it into a DateTimePlus (my own extended class). What's the best way to do this plz ? Some code: class DateTimePlus extends DateTime { static function setFromGUIDateAndTime($date,$time ){ $string = $time.' '.$date; //echo 'str:'.$string; $res = parent::createFromFormat("H.i d.m.Y", $string); return (DateTimePlus)parent::createFromFormat("H.i d.m.Y", $string); } Thk you matt

« previous php.general (#308508) next »