Convert Date from 01-31-2007 to 2007-01-31 (not to 1969-12-31)
July 24th, 2009 |
|
0 Comments »
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-













Comments (0)
Trackbacks - Pingbacks (0)
Leave a Reply