user1314836
user1314836

Reputation: 239

date/time stored in SQL but checked from PHP--format DATETIME or TIMESTAMP?

I want to add the date/time of the moment when a row was inserted for the first time.

There are two different date/time formats, depending on if it's going to be used in SQL or PHP. It's going to be stored in SQL so that I can check this time from a PHP application.

What should the data type be, DATETIME or TIMESTAMP?

How do I insert the current date/time by default?

Upvotes: 0

Views: 63

Answers (1)

Hardy
Hardy

Reputation: 1539

You can implement an trigger on insert, update that table, and call update your datetime column whenever with now()

Upvotes: 1

Related Questions