s_ainley87 Posted January 12, 2009 Share Posted January 12, 2009 How can i insert the current datetime in my msql table using php, I ahve tried assing a variable like this $date = date("Y M D"); and send that but that does not work all i get is the default 0000-00-00 00:00:00. Any help out there? Thanks Quote Link to comment https://forums.phpfreaks.com/topic/140516-send-current-date-and-time-to-mysql-datetime-field/ Share on other sites More sharing options...
revraz Posted January 12, 2009 Share Posted January 12, 2009 Just use the MySQL NOW() Quote Link to comment https://forums.phpfreaks.com/topic/140516-send-current-date-and-time-to-mysql-datetime-field/#findComment-735316 Share on other sites More sharing options...
s_ainley87 Posted January 12, 2009 Author Share Posted January 12, 2009 the qeury is built by Zend and _save function so I can't i dont think Quote Link to comment https://forums.phpfreaks.com/topic/140516-send-current-date-and-time-to-mysql-datetime-field/#findComment-735320 Share on other sites More sharing options...
ngreenwood6 Posted January 12, 2009 Share Posted January 12, 2009 Why don't you just save it as a timestamp? you can convert timestamps back to a date. Alot easier and better for storage. Quote Link to comment https://forums.phpfreaks.com/topic/140516-send-current-date-and-time-to-mysql-datetime-field/#findComment-735339 Share on other sites More sharing options...
premiso Posted January 12, 2009 Share Posted January 12, 2009 Obviously that will not work, look at the format. $date = date("Y-m-d H:i:s") It should enter properly using that. Quote Link to comment https://forums.phpfreaks.com/topic/140516-send-current-date-and-time-to-mysql-datetime-field/#findComment-735340 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.