On 29/07/14 17:23, Will Fong wrote:
> Ah! I have not explained my issue properly :)  I'm very sorry about that.
> 
> I'm using SQLite as a backend to a small website and I have users in
> multiple timezones. When users login, their timezone is retrieved from
> the user table.

Why do you even need to store their timezone?  The only time it would matter
is if you are showing one user what another users local time is.

The way I do this with web stuff is let the browser handle it.  The page is
rendered at the server with some reasonable default (UTC), and then
javascript in the browser updates it for the local timezone and preferences.
 eg:

<span class="timestamp" data-timestamp="1406738691">
   2014-07-30 16:43 UTC
</span>

The Javascript then replaces the text with "7/30/2014 9:43" and leaves the
tooltip as the UTC time.  We usually make the text more useful - for example
it may say "30 minutes ago", "Tuesday at 2pm", "3 years ago" etc and
automatically update as the page is left open.  This is the library we use,
but there are many out there:

  https://mattbradley.github.io/livestampjs/

This approach means there is no need to store timezones, and that the
formatting (eg 24 hr versus am/pm, timezone) are picked up from their
browser and OS preferences.

Roger
_______________________________________________
sqlite-users mailing list
sqlite-users@sqlite.org
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to