ukscotth Posted September 1, 2011 Share Posted September 1, 2011 Hi, Im having some troubles with a date picker on a form. It enters the date into the date field like this : 21 Sep 2011 I want to be able to insert it into a date field in the mysql database but it just enters it as 0000-00-00 Any ideas ? Many thanks, Scott. Link to comment https://forums.phpfreaks.com/topic/246188-problem-with-form-date-picker/ Share on other sites More sharing options...
micah1701 Posted September 1, 2011 Share Posted September 1, 2011 <?php $date_from_date_picker = "21 Sep 2011"; $mysql_friendly_date_string = date("Y-m-d", strtotime( $date_from_date_picker ) ); ?> also, you can probably configure the datepicker to give you the format you want too. but thats a different forum Link to comment https://forums.phpfreaks.com/topic/246188-problem-with-form-date-picker/#findComment-1264374 Share on other sites More sharing options...
premiso Posted September 1, 2011 Share Posted September 1, 2011 Use the DateTime class and see if it will handle the conversion. Particularly, the CreateFromFormat function. Link to comment https://forums.phpfreaks.com/topic/246188-problem-with-form-date-picker/#findComment-1264375 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.