RE: [PHP-DB] Insert Date

From: Date: Sat, 15 Mar 2003 21:12:35 +0000
Subject: RE: [PHP-DB] Insert Date
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-26399@lists.php.net to get a copy of this message
> I'm having problem inserting the date into my mysql database. What type > of field should my date field be? > How do I insert that into a database, the current date for example? > "INSERT INTO tblDate (fldDate) VALUES (" . Date() . ")"; You should use a DATE column, maybe?? Or a timestamp, depending on what you want to do. The query you'd use is: INSERT INTO tblDate (fldDate) VALUES (NOW()) where NOW() is a MySQL function, not a PHP one. MySQL date formats are YYYYMMDD (as an integer) or YYYY-MM-DD (as a string). Adapt to your needs. ---John W. Holmes... PHP Architect - A monthly magazine for PHP Professionals. Get your copy today. http://www.phparch.com/

« previous php.db (#26399) next »