inther Posted December 21, 2009 Share Posted December 21, 2009 I'm trying to use the date function to get it passed to a variable within a function that is in a class. Then a mysql query stores it in the database. The function inserts data into the database as below; $app_date is declared as a variable in the class var $app_date; Then in the function that inserts data into the database, the variable $app_date receives the current date $app_date = date("Y-M-D"); Then within the same function, i use the variable $app_date to insert the date into the database $query = "INSERT INTO tablename (app_date,) VALUES ('$app_date')"; mysql_query($query) or die(mysql_error()); but then when i check the database, all i see in the field is "0000-00-00" How can i get the current date to be passed to the given variable in the php function and then stored into Mysql? Link to comment https://forums.phpfreaks.com/topic/185940-help-with-date-storage/ Share on other sites More sharing options...
Roq Posted December 21, 2009 Share Posted December 21, 2009 The (app_date,) should be (app_date) I believe, are you getting errors on the insert query? Link to comment https://forums.phpfreaks.com/topic/185940-help-with-date-storage/#findComment-981897 Share on other sites More sharing options...
PFMaBiSmAd Posted December 21, 2009 Share Posted December 21, 2009 The date() format string - "Y-M-D" produces 2009-Dec-Mon. You should be using "Y-m-d" Link to comment https://forums.phpfreaks.com/topic/185940-help-with-date-storage/#findComment-981907 Share on other sites More sharing options...
inther Posted December 22, 2009 Author Share Posted December 22, 2009 Thanks, i managed to resolve it using curdate() Link to comment https://forums.phpfreaks.com/topic/185940-help-with-date-storage/#findComment-982079 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.