insert into the database date and the time

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
mingo
Forum Newbie
Posts: 9
Joined: Fri Nov 22, 2002 3:46 am
Location: London

insert into the database date and the time

Post by mingo »

I am using an HTML form to insert information into a database using PHP and mySQL. (information such as surname, name, email,...)

Does anyone know how to insert into the database the date and the time when the user inputs this information without creating a field in the HTML form?

Thank you very much. :?:
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

If you create a DATETIME field in your database table then you can just set that to NOW() in your INSERT statement, eg.:

Code: Select all

INSERT INTO table (field1, field2, field3, datetimefield) VALUES(formdata1, formdata2, formdata3, NOW())
Mac
Post Reply