For PHP 5.3.5 this works(worked on my development environment)
$orgdate=DateTime::CreatefromFormat('d-m-Y',$orignaldate);
$converteddate=$orgdate->format('Y-m-d');
In case of 5.2.4 I used the Cakephp Helper to convert the same so check your framework you might have a helper for the same for core PHP you might need to play with Date function
Here is how it went in case of cakephp
Add this line to the top of your view/controller
App::import('Helper','Time');
$time=new TimeHelper //create object of class
$data['date']='28-07-2011';
$time->format('Y-m-d',$data['date']);
worked on hosting env i.e php 5.2.4
No comments:
Post a Comment