Reputation: 6116
I have a database where people register on a website and their form data then gets inserted into their database. Along with all that information, I want to insert the time of their registration. For example I have an auto-incrementing ID column which I do nothing in my php script for, the sql database automatically increments that with every new entry. In the same way, can I have a time column that I don't have to do anything in the script for, rather the database will just get the current time and put that along with the other inserted information? I'm using phpMyAdmin and I tried adding a column named Time with the type as DATETIME
and the default value as the CURRENT_TIMESTAMP
but it woulnd't let me add that and said invalid default value for Time.
Upvotes: 0
Views: 422
Reputation: 4046
use timestamp
column type e.g.
`inserted` timestamp NOT NULL default CURRENT_TIMESTAMP
Upvotes: 1