0

I have a problem where I need to handle changes in the timezones and changes in the days within the same timezone while saving and then retrieving the records in the database. The two solutions that I could think of yet are, use UTC+0 timezone on the server, OR, send timezone of client each time while saving the record and then use that timezone value while retrieving the record. The former one can handle changes in the timezones of the client but does not handle the problem where client wants to query all the records of a particular day because the change in day won't be at the same time for the server and the client. The latter solution handles the problem of difference in the day change time but does not handle change in the timezone of the same client. What other solution could be there which can handle both the problems?

Ole V.V.
  • 81,772
  • 15
  • 137
  • 161
Fawad Khalil
  • 161
  • 1
  • 2
  • 11
  • 1
    Hi. Please read [*How do I ask a good question?*](https://stackoverflow.com/help/how-to-ask). We know nothing of your server, client, application, which database, programming language, what types of records, the use cases you are trying to solve, etc. Such supporting details with specific examples are necessary to address your question. Also please *search* and *search again* because this topic has been discussed at great length many times from many different perspectives. The [tag:timezone] tag has a lot in this area. – Matt Johnson-Pint Mar 29 '21 at 18:27
  • Does this answer your question in whole or in part? [Java Best Practice for Date Manipulation/Storage for Geographically Diverse Users](https://stackoverflow.com/questions/40075780/java-best-practice-for-date-manipulation-storage-for-geographically-diverse-user) – Ole V.V. Mar 29 '21 at 19:00
  • When the client wants, say, all records for 20 March, in converts the start and the end of that day to UTC and pass both points in time to the server. It then retrieves records that fall between those two points. It’s not that hard. – Ole V.V. Mar 29 '21 at 19:02
  • Does this answer your question? [Java Best Practice for Date Manipulation/Storage for Geographically Diverse Users](https://stackoverflow.com/questions/40075780/java-best-practice-for-date-manipulation-storage-for-geographically-diverse-user) – Ole V.V. Mar 30 '21 at 19:03
  • Yes, @OleV.V. that would definitely work. Thank you. – Fawad Khalil Mar 31 '21 at 08:11

0 Answers0