Reputation: 103
I already read all the documentation and previous answers but all they explain are the technical differences and not what the common use is for...
I want to save creation and modification date. Should I use datetime
and timestamp
?!?! Or timestamp
for both?
I understand that if creation date doesn't change I should use datetime
, but I've seen some people use timestamp too.
Thanks in advance, Leandro.
Upvotes: 2
Views: 748
Reputation: 4214
I would recommend using timestamp
for both.
It can be confusing switching between timestamp
and datetime
, so it's easier to just keep everything the same.
Note that some limitations of timestamp
is that it has a range of 1970-01-01 00:00:01 UTC to 2038-01-19 03:14:07 UTC
. This can be troublesome if you're dealing with birthdays and the like (that would be a use case for datetime
).
An advantage of timestamp
is that it's always converted to UTC. So if you're serving data to different timezones it's automatically converted to their respective location.
Upvotes: 2