Convert Date from 01-31-2007 to 2007-01-31 (not to 1969-12-31)

Question:

Users can input any date string, such as   “01-31-2007″
and $date = $_POST['date_in'];

But for inserting into MySQL, I want to change it into “2007-01-31″.
I tried this:

$Task_Date = date(“Y/m/d”,strtotime($date));

But it always shows  “1969-12-31″ regardless of what the input was.
What am I doing wrong?

Solution:

Then use:

list($m, $d, $y) = explode(‘-’, $date);

$Task_Date = $y.’-’.$m.’-’.$d;

-r-

Tags: ·
digg delicious stumbleupon technorati Google live facebook Sphinn Mixx newsvine reddit yahoomyweb
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...