sugarplum_19 Posted April 5, 2011 Share Posted April 5, 2011 I have a drop down menu where the user can select the date, when the user save the data, into phpmyadmin it saves the date as 0000-00-00, any ideas why it saves the date like this. Do i need to convert from a string to a date. Quote Link to comment https://forums.phpfreaks.com/topic/232749-date/ Share on other sites More sharing options...
drisate Posted April 5, 2011 Share Posted April 5, 2011 Well it save the date like that because thats how it has been inserted ... if you wish to break down the date your can do it like this: $date = explode ('-', $date); $year = $date[0]; $month = $date[1]; $day = $date[2]; (assuming the month was parameter 2 ... Quote Link to comment https://forums.phpfreaks.com/topic/232749-date/#findComment-1197170 Share on other sites More sharing options...
Pikachu2000 Posted April 5, 2011 Share Posted April 5, 2011 If it's saving it literally as all zeroes, it usually indicates you're trying to insert an invalid value. You need to insert it in the YYYY-MM-DD format for it to be valid. Quote Link to comment https://forums.phpfreaks.com/topic/232749-date/#findComment-1197173 Share on other sites More sharing options...
drisate Posted April 5, 2011 Share Posted April 5, 2011 $date = date("Y-m-d"); Quote Link to comment https://forums.phpfreaks.com/topic/232749-date/#findComment-1197178 Share on other sites More sharing options...
Pikachu2000 Posted April 5, 2011 Share Posted April 5, 2011 That doesn't do what the OP wants. That will just return the current date. The value is coming from a form, so the formatting needs to be done prior to the insert query. Without seeing the form and code being used to process it, there's no real way to answer with anything more specific. Quote Link to comment https://forums.phpfreaks.com/topic/232749-date/#findComment-1197181 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.