limecity Posted May 6, 2007 Share Posted May 6, 2007 I made a php form which enable the user to select a date and submit, it will enter the database with this code: $_POST['indate'] = date("Y",time())."-".$_POST['ciMM']."-".$_POST['ciDD']; $_POST['outdate'] = date("Y",time())."-".$_POST['coMM']."-".$_POST['coDD']; I also manage to output the date with this coding <?php while ($row = mysql_fetch_array($result)) { echo'<tr><td>' '</td><td>'.$row['indate'].'</td><td>'.$row['outdate'].'</td><td> </td></tr>'; } ?> but the output became this "2007-09-06" format. PROBLEM How do i output it to be like 2007-September-06 ? Quote Link to comment Share on other sites More sharing options...
dzysyak Posted May 6, 2007 Share Posted May 6, 2007 You should use DATE_FORMAT(date,format) function. Read MySQL manual for details Quote Link to comment Share on other sites More sharing options...
triphis Posted May 6, 2007 Share Posted May 6, 2007 you could save yourself some time by simply storing the times plainly (without all your formatting) like, just a timestamp... but then PULL IT OUT with the formatting. You would pull from your mysql table with: SELECT DATE_FORMAT('date_column','%Y-%M-%d') AS date..... Quote Link to comment Share on other sites More sharing options...
limecity Posted May 6, 2007 Author Share Posted May 6, 2007 oh. thanks for the reply. okay, i might try diff approach. my form is a plain html with two drop down bar [day] [month] for the user selection as you see here $_POST['indate'] = date("Y",time())."-".$_POST['ciMM']."-".$_POST['ciDD']; $_POST['outdate'] = date("Y",time())."-".$_POST['coMM']."-".$_POST['coDD']; ciMM is the variable for Month ciDD is the varibale for Date ------------------ as you suggested, how do i insert those data into the database as plain format and pull it out with formating inside the table created on the page? Quote Link to comment Share on other sites More sharing options...
limecity Posted May 7, 2007 Author Share Posted May 7, 2007 <bump> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.