Reputation: 1092
I'm struggling to make a decision between timestamp and datetime. I did fint similar questions, but none gave me a definite answer.
The scenario is as follows:
I have to account for DST and all date & time related things. I believe dates should be stored in UTC timezone being neutral.
So my question is whether someone could provide me a workflow they utilized in this situation?
I was thinking that in PHP I would use DateTime obviously and:
Is there any drawback of my workflow?
I will be using Symfony 2, so any Symfony 2 workflow would be best, but other than that I will take anything!
Upvotes: 0
Views: 632
Reputation: 5877
Your workflow is fine.
Whenever you need to fulfil multi timezone requirement, it is better to store time in database as utc timestamp or unix epoch. unix epoch is well supported and i would suggest this. Even from the client side you can send unix epoch to the server without worrying about timezone. If you use utc timestamp you will need to convert between timezones. with unix epoch it is still conversion but it is very straight forward and well supported in most of the date object constructs.
And when you need to retrieve and display time, you will construct the date object using unix epoch and the time zone for that user.
Upvotes: 1