Possible Duplicate:
PHP/MySQL – Format date/time
I have input field (name:day1 and varchar) to enter date in my form. It attached with a jquery calendar and picks the date in the format “D, dd M, yy” (I WANT TO PICK LIKE THIS AND CANT CHANGE FORMAT). I want to convert and save into mysql date format into table. How is this possible?
$insert_query = 'insert into '.$this->tablename.'(
venue,
day1,
day2,
day3,
day4,
day5,
day6,
day7,
day8,
day9,
day10,
city,
contactperson,
)
values
(
"' . $this->SanitizeForSQL($formvars['venue']) . '",
"' . $this->SanitizeForSQL($formvars['day1']) . '",
"' . $this->SanitizeForSQL($formvars['day2']) . '",
"' . $this->SanitizeForSQL($formvars['day3']) . '",
"' . $this->SanitizeForSQL($formvars['day4']) . '",
"' . $this->SanitizeForSQL($formvars['day5']) . '",
"' . $this->SanitizeForSQL($formvars['day6']) . '",
"' . $this->SanitizeForSQL($formvars['day7']) . '",
"' . $this->SanitizeForSQL($formvars['day8']) . '",
"' . $this->SanitizeForSQL($formvars['day9']) . '",
"' . $this->SanitizeForSQL($formvars['day10']) . '",
"' . $this->SanitizeForSQL($formvars['city']) . '",
"' . $this->SanitizeForSQL($formvars['contactperson']) . '",
)';
day 1 to day 10 are the dates want to convert…
or in the sql statement you can do that:
The “%W, %d %M, %y” bit must be in the same format as the date you get from your calendar…
To check all date functions and dates format see these links:
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_date-format
http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_str-to-date
I hope that helps…