Apr 10, 2003 #1 KryptoS Programmer Feb 7, 2001 240 BE Hey, I want to put the current date and time in my database. But don't know how I can get them? I thougt: $cDate = getdate(); $cTime = ????? but it only puts 0000-00-00 in my database ... can someone help me? The One And Only KryptoS
Hey, I want to put the current date and time in my database. But don't know how I can get them? I thougt: $cDate = getdate(); $cTime = ????? but it only puts 0000-00-00 in my database ... can someone help me? The One And Only KryptoS
Apr 10, 2003 #2 sleipnir214 Programmer May 6, 2002 15,350 US Insufficient data for a meaningful answer. You did not specify which database backend you are using -- I will assume MySQL and answer. MySQL expects a date to be a string of the form YYYY-MM-DD. getdate() returns an array. You can use MySQL's "now()" function to insert the date on the database side: INSERT INTO table_name (date_col) values (now()) You can use: $cDate = date ('Y-m-d'); to set $cDate to a date string MySQL can use from the PHP side. Want the best answers? Ask the best questions: http://www.catb.org/~esr/faqs/smart-questions.htmlTANSTAAFL! Upvote 0 Downvote
Insufficient data for a meaningful answer. You did not specify which database backend you are using -- I will assume MySQL and answer. MySQL expects a date to be a string of the form YYYY-MM-DD. getdate() returns an array. You can use MySQL's "now()" function to insert the date on the database side: INSERT INTO table_name (date_col) values (now()) You can use: $cDate = date ('Y-m-d'); to set $cDate to a date string MySQL can use from the PHP side. Want the best answers? Ask the best questions: http://www.catb.org/~esr/faqs/smart-questions.htmlTANSTAAFL!