I have to import a database from an existing site into the new site which we have made. The dob fields stored in the earlier db is creating problem. There dob format is mm/dd/yy or mm/dd/yyyy, whereas we need to save in Y-m-d format.
I m using this code,which works fine for date
$case_contact_dateval = '04/11/81';
and gives me date 1981-04-11, which is correct. Whereas in
$case_contact_dataval = '03/22/67';
$date = DateTime::createFromFormat('m/d/y',$case_contact_dataval);
echo $date = $date->format('Y-m-d');
Some other dates are
$case_contact_dataval = '03/22/67';
$case_contact_dataval = '07/05/40';
$case_contact_dataval = '01/25/59';
$case_contact_dataval = '03/09/58';
I get date as 2067-03-22, which is wrong as all these dates are date of birth. I m using php 5.4.6 on ubuntu. I have many like these dates for which the same code works fine and for some wrong. Can't get a soln... Please advice.