Solarpitch Posted July 20, 2009 Share Posted July 20, 2009 Hey, Just wondering... I'm taking a date in the format "07/13/2009" and its going to be stored in the database as DATE but it just seems to store as 0000-00-00 .. how can I convert this format so that it goes into the databse in the correct format? Quote Link to comment https://forums.phpfreaks.com/topic/166629-solved-date-format-question/ Share on other sites More sharing options...
rhodesa Posted July 20, 2009 Share Posted July 20, 2009 $date = '07/13/2009'; $db_date = date('Y-m-d',strtotime($date)); Quote Link to comment https://forums.phpfreaks.com/topic/166629-solved-date-format-question/#findComment-878657 Share on other sites More sharing options...
JonnoTheDev Posted July 20, 2009 Share Posted July 20, 2009 Mysql requires american date format YYYY-MM-DD. Akward aren't they like spelling colour without a u! <?php // 1st nov 2009 $date = "01/11/2009"; $date = implode("-",array_reverse(explode("/",$date))); print $date; ?> or use strtotime() function with date() Quote Link to comment https://forums.phpfreaks.com/topic/166629-solved-date-format-question/#findComment-878659 Share on other sites More sharing options...
Solarpitch Posted July 20, 2009 Author Share Posted July 20, 2009 Haha exactly ... thanks for the helps guys. Thats perfect. Quote Link to comment https://forums.phpfreaks.com/topic/166629-solved-date-format-question/#findComment-878663 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.