[SOLVED] auto date won't show up in database

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
monkeynme
Forum Commoner
Posts: 28
Joined: Thu Aug 14, 2003 3:18 pm
Location: Colorado Springs, CO

[SOLVED] auto date won't show up in database

Post by monkeynme »

I have a PHP form which allows a job candidate to fill in information and upload a resume. The submission date is a field in the database which is supposed to automatically log the date of submission when the info is added. As such, there is no DATE field to fill in on the form. However, when the data is inserted, everything is entered...except for the DATE. It reads 0000-00-00 instead of the appropriate date.

Is there some extra setting needed on the DATE field in the database to make it work? Or am I supposed to put some kind of HIDDEN INPUT code for the submitDate field in the form itself?
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 want the current date to be updated without intervention from yourself, use a TIMESTAMP field, this will change every time the data is added or updated.

However, if this is simply a date added field, then you should use MySQL's NOW() function when doing your insert, e.g.

Code: Select all

INSERT INTO your_table (column1, column2, date_added) VALUES('value1', 'value2', NOW())
Mac
monkeynme
Forum Commoner
Posts: 28
Joined: Thu Aug 14, 2003 3:18 pm
Location: Colorado Springs, CO

Post by monkeynme »

Fantastic! I knew it had to be something easy. Thanks!
Post Reply