RE: Insert Date

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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:  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/






-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux