RE: [PHP-DB] Insert Date
| From: | Jeremi Bergman | Date: | Sun, 16 Mar 2003 23:48:20 +0000 |
| Subject: | RE: [PHP-DB] Insert Date | ||
| References: | 1 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-26409@lists.php.net to get a copy of this message | ||
Thank you,
How would I do the insert statement in php using a date() or now()
function?
-----Original Message-----
From: John W. Holmes [mailto:holmes072000@charter.net]
Sent: Saturday, March 15, 2003 4:13 PM
To: 'Jeremi Bergman'; php-db@lists.php.net
Subject: RE: [PHP-DB] Insert Date
> 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/