vecino Well-Known Member Licensed User Longtime User Sep 18, 2014 #1 Hi, I have the following problem: My timezone is GMT +2 A field of a table has default CURRENT_TIMESTAMP The table must be saved GMT +2 However, keep GMT What I can do? Attachments 1-timezone.png 26.6 KB · Views: 566 2-date-command.png 23.3 KB · Views: 552 3-table-structure.png 21.5 KB · Views: 479 4-insert-row.png 27.9 KB · Views: 630 5-result.png 12.6 KB · Views: 560
Hi, I have the following problem: My timezone is GMT +2 A field of a table has default CURRENT_TIMESTAMP The table must be saved GMT +2 However, keep GMT What I can do?
Erel B4X founder Staff member Licensed User Longtime User Sep 18, 2014 #2 I'm sorry but I'm not sure that I understand. Which value are you looking for? Upvote 0
eps Expert Licensed User Longtime User Sep 18, 2014 #3 Correct. Current Time (timezone 0) is 15:40. You see 15:40 + 2 i.e. 17:40. You need to store the Timezone difference for the User and then 'add' it to the Time retrieved. TimeZone offset or something similar... I think. Upvote 0
Correct. Current Time (timezone 0) is 15:40. You see 15:40 + 2 i.e. 17:40. You need to store the Timezone difference for the User and then 'add' it to the Time retrieved. TimeZone offset or something similar... I think.
eps Expert Licensed User Longtime User Sep 18, 2014 #4 I think you need to be clear about what you are doing and what information you need to store along with the Time... Unfortunately it's a little more complicated than just adding timezones. i.e. time is stored (timezone 0?) or possibly timezone with a local timezone and then displayed with a remote timezone to take in to account.. Without more information about what you're trying to achieve it's a bit hard to help. Upvote 0
I think you need to be clear about what you are doing and what information you need to store along with the Time... Unfortunately it's a little more complicated than just adding timezones. i.e. time is stored (timezone 0?) or possibly timezone with a local timezone and then displayed with a remote timezone to take in to account.. Without more information about what you're trying to achieve it's a bit hard to help.
vecino Well-Known Member Licensed User Longtime User Sep 18, 2014 #5 Hi, thanks for replying. If they are 17:32 I think you should record in the database: 17:32 But save 15:32 2 hours ahead of GMT Let me explain: Madrid, GMT +2 It's 17:00 local time. In the database, when a record is saved, "CURRENT_TIMESTAMP" stores 15:00 What I can do to "CURRENT_TIMESTAMP" store 17:00? Last edited: Sep 18, 2014 Upvote 0
Hi, thanks for replying. If they are 17:32 I think you should record in the database: 17:32 But save 15:32 2 hours ahead of GMT Let me explain: Madrid, GMT +2 It's 17:00 local time. In the database, when a record is saved, "CURRENT_TIMESTAMP" stores 15:00 What I can do to "CURRENT_TIMESTAMP" store 17:00?
eps Expert Licensed User Longtime User Sep 18, 2014 #7 It may well be that you need to look a little further in to sqlite I'm not sure if it can handle the timezone or you take the calculation out of the sql statement and then process it in B4A and then pump the value in to sqlite. It's not something I've had to consider. Upvote 0
It may well be that you need to look a little further in to sqlite I'm not sure if it can handle the timezone or you take the calculation out of the sql statement and then process it in B4A and then pump the value in to sqlite. It's not something I've had to consider.
vecino Well-Known Member Licensed User Longtime User Sep 18, 2014 #9 Hi, I think I've found the solution. Example: Code: Copy CREATE TABLE tbXXX ( id integer not null primary key autoincrement, tipo integer not null default 0, fechahoraold timestamp default (datetime('now','localtime')), fechahoranew timestamp default CURRENT_TIMESTAMP ) Using (datetime('now','localtime')) is stored in the database local time. Upvote 0
Hi, I think I've found the solution. Example: Code: Copy CREATE TABLE tbXXX ( id integer not null primary key autoincrement, tipo integer not null default 0, fechahoraold timestamp default (datetime('now','localtime')), fechahoranew timestamp default CURRENT_TIMESTAMP ) Using (datetime('now','localtime')) is stored in the database local time.