I have a problem when i am converting a String Date datatype into a date time format. I am using this code
$birthday = date('Y-m-d', strtotime($rec['birthday']));
The problem is that when only 'Date-Month' fields are coming then it will generate by default '1970'.But i want to save this as 'Date-Month-0000'.how can we solve this problelm.
try this.
$rec['birthday']= "03/11/2011";
if(isset($rec['birthday']) && $rec['birthday'] != "")
{
$dates = explode("/",$rec['birthday']);
if(!isset($dates[2]))
$dates[2] = "0000";
$newdate = $dates[0]."-".$dates[1]."-".$dates[2];
echo $newdate;
}
else
{
$newdate="";
}
NOTE: $rec['birthday']
should be in format DD/MM
or DD/MM/YY
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments