In my table I have a dateCreated column in the format of DATETIME.
How do I insert the current datetime when I add the record to the database?
In my table I have a dateCreated column in the format of DATETIME.
How do I insert the current datetime when I add the record to the database?
Better use TIMESTAMP
instead and use CURRENT_TIMESTAMP
to get current timestamp. TIMESTAMP
should behave exaclty (or very similar) to DATETIME
so you shouldn't notice a difference.
Furthermore you may set CURRENT_TIMESTAMP
as default for all new entries.