PDA

View Full Version : Inserting Current Date into MySql


zuffster370186
04-05-2009, 10:18 AM
I have never been able to do this but how does one record the current date of a new registered user into MySql? I have set up a column in my database 'user_reg_date' but when a new record is put into the database, the date field only shows '0000-00-00'. I need the current date to be recorded in the user_reg_date column when someone registers. I would appreciate the help

Ray Borduin
04-06-2009, 09:41 AM
The easiest way is to set the field as a timestamp and set its default value to: CURRENT_TIMESTAMP.

This way the database will do it for you.

Another option is to use <?php echo(date('Y-m-d H:i:s')); ?> as the value for that column.