Thursday, January 13, 2022

[FIXED] Auto TimeStamp new entry to DB (phpMyAdmin)

Issue

If I want each new entry into my db to be automatically timestamped, would I set the Field Type to "timestamp" and have the Default value set to "CURRENT_TIMESTAMP"?

Is this the correct method?


Solution

That is correct. In SQL code that would be:

CREATE TABLE `table` (
    ...
    `date` TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP, 
    ...
)


Answered By - BoltClock

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.