TimeZone confusion

Hi y’all,

I’m storing logging information on a Xojo cloud app, storing at GMT0
Then when I display it, I try to get the current timezone so I can display it in a regionally meaningful way to the user.
This works great while debugging, but on the server my logged activity at 2pm shows up at 7pm, which is GMT0. I thought maybe my server was in GMT0, but I kind of doubt it.

Any thoughts?

Hi Chris,

The issue is that DateTimeValue returns the date using the current timezone of the machine where the app is being run. You need to use the datetime fromstring method to get the datetime in the timezone that relates to the stored value, you can then convert that value to the users timezone.

I’ve just posted a couple of extension methods I use for this purpose at https://forum.xojo.com/t/database-datetimevalue-extensions/68880


Maybe I’ve miscommunicated a bit.
I create the time stamp using DateTime.Now, passing a timezone with 0 offset.
I store it in the database as an string
I recall it from the database as a DateTime and then get the current system’s current timezone’s second offset.
I create a dateinterval with that number of seconds and add it to the retrieved date time.

In my (peanut-sized) mind, this should work. And… it works find when running on my local system where I can debug and see the date time being stored and recalled referencing GMT0 and then altering to Eastern.

In Web 1.0 I used Websession.GMTOffset to set DateTime.GMTOffset to adjust any dates for display. I see they have changed things in Api 2 and I no longer see a GMTOffset property on Websession. Websession.GMTOffset would already be set to match the Timezone of the browser accessing. Sounds like you need a similar property to set the new Timezone property.

Thank you Steve, this was what I was looking for and not finding.
For now I’m ok because my customer says he within 24 hours is good enough for now, but it’s bothering me and I want to figure this out for other apps.

Looks like Websession.ClientTime may be somewhat equivalent as it gives you a date object with the browsers current timezone

1 Like

I’ll test. Thank you, Steve.

The time on Xojo Cloud servers are in fact GMT no matter where they are in the world.


And that’s great. I am dealing with some external APIs with confusing “standards” like “PST never reflecting summer time” according to their docs but still changes 2 times a year :-). Using one standard on server side, and leaving it up to the developer to deal with it seems to be the right approach to me.

1 Like