British summer time adjustments

Hi all,

I have designed a standalone web app located on windows azure virtual machine, which talks to a sql database located on my 123-reg vps.

Records are saved with a date stamp using .SQLdateTime

When I run my web app via my mobile phone or pc I get gmt rather than british summer time (ie the time stamp saved to the SQL being 1 hr earlier than my local time).

The application will be accessed globally and needs to provide a datestamp with the local time.

How could I acheive this?

Thanks in advance.

If the app is accessed globally, you probably are better of with a globally valid time stamp (UTC / GMT).

thanx Eli how do I access utc/gmt?

http://documentation.xojo.com/index.php/Date.GMTOffset

Frederic, this method is fine, but what about time zones that have daylight savings time? How do you set the offset such that it is always correct in such time zones?

I thought Britain was on BST (British Standard Time) :slight_smile:

Hi Louis - though this isn’t spelled out in the LR, it appears to me that GMTOffset information is pulled from the local operating system settings. So if the local OS respects daylight savings time, the Date.GMTOffset does as well.

James - as far as getting UTC time, you can set your server’s timezone to UTC or you can set a date object to the current date/time on the server and then set it’s GMTOffset to 0, that will convert the date/time stored in the date object to a UTC timezone value. Something like:

dim d as new date //automatically set to the current date/time by being instantiated

d.GMTOffest = 0 //converts the stored date/time to the corresponding UTC value

date_string_for_SQL = d.SQLdateTime //creates an SQL Date formatted string

As far as getting date information. If you’re hosting your own server, you can probably rely on it’s date settings to be correct. You can also query an NTP server, which will return a UTC timestamp. Greg O’Lone from Xojo recently shared on the forums, an NTP class he wrote years ago. I’ve cleaned it up a bit for Xojo. It demonstrates some of these ideas.

It’s available here.

I hope that helps a bit! :slight_smile:
Anthony

I would store the time in local (server) time zone, then set Date.GMTOffset = Session.GMTOffset to display it in the user’s time zone.

I think Anthony answered those questions very well.

Consider storing dates/times with GMTOffset set to 0 so regardless of where the database resides, or gets moved to, the date/time is always GMT/UTC. When it is presented to users, it can then be converted to their local time zone.