PHP to MySQL Date Format

Default MySQL DATE Column is in '2012-07-18 10:20:32'  format

We must be using some input box or calender script in Webpages to enter a date .
If the Date inserted is not in Format of MySQL it wont get saved to DB.
So when we insert a Date Value from PHP into a database column we need to format according to MySQL.

For this we can use MySQL STR_TO_DATE().
Syntax: STR_TO_DATE(Str,format);
Str is the DATE string  and Format is the format of Str.
Please remember this function always return a DATE in 'YY-MM-DD' format.

eg:
SELECT STR_TO_DATE('18-7-2012','%d-%m-%Y')
prints : 2012-07-18
we mention is the second argument the format in which we pass the Str which has a date.
if we pass the Str in '2012/07/18' (ie YY/MM?DD)
SELECT STR_TO_DATE(' 2012/07/18 ','%Y / %d / %m')
prints : 2012-07-18