0

I have an app which will work in multiple timezones. I need the app to be able to say "Do this at 10 PM, 12 April, 2015, in the America/New York timezone and repeat every 30 days." (And similar).

If I get a datetime from the user in PST, should I be storing the datetime in DB after converting to UTC?

Pros: Easier to manage, every datetime in DB is in UTC. Cons: Can not take DST in account. (I think).

shabda
  • 1,668
  • 1
  • 18
  • 28
  • related: [Is it always a good idea to store time in UTC or is this the case where storing in local time is better?](http://stackoverflow.com/q/11537106/4279) – jfs May 15 '14 at 18:02

2 Answers2

1

You mean UTC?

The database should handle all the logic about the time / timezone. You need to provide the right timezone to the database, then the database store it and provide it to the client for the timezone requested. For example the types in postgresql: here

What's your database?

FlogFR
  • 729
  • 7
  • 14
1

Yes, you should store everything in your db in UTC.

I don't know why you say you won't be able to cope with DST. On the contrary, any good timezone library - such as pytz - is quite capable of translating UTC to the correct time in any timezone, taking DST into account.

Daniel Roseman
  • 588,541
  • 66
  • 880
  • 895
  • Eg: 11 AM CA Every 10th of month won't be the same time in UTC every month. It could be 6PM or 5PM depending on whether DST are in effect. – shabda May 15 '14 at 11:59