I have a jquery calendar that sets the input value to MM/DD/YYYY
How would I convert it so that my database column (date) can accept it correctly?
EDIT
I will suggest to use strtotime()
function and then date()
. By this you can convert any format of date.
$unix_time_stamp = strtotime($mm_dd_yyyy);
$yyyy_mm_dd = date(Y/m/d,$unix_timestamp);
assign the date values to variable $d
$dob
denotes the date which you wish to convert
$d= date('Y-m-d',strtotime ($dob) );
$date = "07/12/2010";
$your_date = date("Y-m-d", strtotime($date));
I hope my answer is useful :)
Alternatively you can do this without using the explode
:
$date = "12/25/2010";
$mysql_date = date('Y-m-d', strtotime($date));
You can now use $mysql_date
to insert into your database.