Can anyone please help me how to convert string to date
I have 3 dropdowns(year,month,date)and i got date value as 2012-january-12.
How can i convert it like 2012-01-12(yyyy-mm-dd).
$dob = $year.’-‘.$month.’-‘.$day;
I used str_to_date(‘$dob’,’%Y-%M-%e’) in the query itself but its stops executing the query.
Here is the query
$sql = "insert into issio_asc_workers (lname_fname_dob, asc_id, asc_lastname, asc_firstname, asc_middlename, asc_dob, asc_phone_mobile, asc_phone_work, asc_ssn,
asc_email, asc_phone_preferred, asc_status, asc_emp_yesno, asc_emp_status, asc_user_type, asc_npi, asc_credentials, asc_committee, asc_speciality,
asc_group, asc_startdate)values ('$lfd', '$ascid', '$lname', '$fname', '$mname',
'str_to_date('$dob','%Y-%M-%e')', '$phCell', '$phOffice', '$ssn', '$email', '$preffered', '$asc_status', '$empType', '$asc_emp_status', '$asc_user_type', '$npi',
'$credential', '$commitee ', '$speciality', '$group', 'str_to_date('$sdate','%Y-%M-%e')')";
Thnaks In advance….,
It is a good idea to marshall your variables before you insert them into your sql query. This is no more difficult for the program to run, but makes your life as a programmer much easier:
This way you can echo
$dob_asDateand ensure it’s what you want.