tags:

views:

17

answers:

2

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?

+4  A: 

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.

nikic
OMG Ponies
A: 

Use the CURDATETIME()

btrandom
We don't know the database - see my comment on nikic's answer
OMG Ponies
oopsie my fault!
btrandom