Hi all,
I'd like to hear from you about how you manage differences in time zones between server and devices, since I can think of a few alternatives and each has its pros and cons.
As long as server and devices share the same TZ there's obviously no problem. On local devices I usually use ADP (AnotherDatePicker) to collect dates, send them as longs to the server which finally stores them on a MySql DB as DATE or DATETIME (in cases when the time component is significant and was added to the ADP result). Looking at data with Toad or similar tool I can see data as originally entered.
When server and devices are on different TZ :
1. One approach could be to prepare on local devices a string in the format expected by the DBMS (e.g. "yyyy-MM-dd"), send it and have the server simply use it as is; the DB will convert from string to DATE.
2. Another approach could be to convert to UTC(0) on the server so to "normalize" data to a common time base. This has the effect that Toad doesn't read the original value but it's conversion to TZ0.
3. Using strings (ok, varchar) instead of date/datetime is another alternative, but I feel it too conservative and limiting in some contexts.
My need is twofold: recording and reading back data irrespective of the TZ where the device currently is (I mean recording 2018-12-31 15:35 in Rome, then moving to NY I should read again 2018-12-31 15:35) and be able to look at as-entered data by Toad.
Hmm, maybe just adding the TZ info to my original data will solve the whole problem..
Anyway, what's your approach?
TIA
I'd like to hear from you about how you manage differences in time zones between server and devices, since I can think of a few alternatives and each has its pros and cons.
As long as server and devices share the same TZ there's obviously no problem. On local devices I usually use ADP (AnotherDatePicker) to collect dates, send them as longs to the server which finally stores them on a MySql DB as DATE or DATETIME (in cases when the time component is significant and was added to the ADP result). Looking at data with Toad or similar tool I can see data as originally entered.
When server and devices are on different TZ :
1. One approach could be to prepare on local devices a string in the format expected by the DBMS (e.g. "yyyy-MM-dd"), send it and have the server simply use it as is; the DB will convert from string to DATE.
2. Another approach could be to convert to UTC(0) on the server so to "normalize" data to a common time base. This has the effect that Toad doesn't read the original value but it's conversion to TZ0.
3. Using strings (ok, varchar) instead of date/datetime is another alternative, but I feel it too conservative and limiting in some contexts.
My need is twofold: recording and reading back data irrespective of the TZ where the device currently is (I mean recording 2018-12-31 15:35 in Rome, then moving to NY I should read again 2018-12-31 15:35) and be able to look at as-entered data by Toad.
Hmm, maybe just adding the TZ info to my original data will solve the whole problem..
Anyway, what's your approach?
TIA