How do I format my dates in PHP?

lyderslim

New member
I'm having troubles figuring out date formats. I have a form where users submit a date range. Then my PHP needs to take those dates and use them in my Select statement to only get results where the "start_date >= passed-in-date" and the "end_date <= passed-in-date2".
The user will submit a date in the format of DD/MM/YY and my query only works if I use "YYYY-MM-DD". How can I "switch" the format the user put in to what the database wants (MySql)
Then when I display the dates, I can't even get that right. I pull dates from the database and do NOT want them to display on my web site as "2010-05-15". So I tried to put the date() function in front of it by doing this "date('m/d/y',$row['start_date']" and I get "01/01/70" -- even though the date is "2010-04-10" before I put the function on it. So it should be "04/10/10".
 
Back
Top