My app uses SQLite timestamps which are UTC. This has been fine for a long time.
But now I need to know the time zone in which a particular record was created.
I am happy to continue to store UTC, but I need to display data to the user using the originating zone.
This could easily be accomplished if SQLite supported a timestamp with timezone (+/-HHMM). It could also be easily accomplished if SQLite had some ability to extract the current timezone in '+/-HHMM' format.
Is there any way to get the 'current' time zone from SQLite? Or to get a timestamp that includes the timezone?
To be clear I like and want UTC. It is good, but I also need the originating TZ. I am happy to store this in another field if necessary. Also happy to store two date fields if necessary.
Edit1: The best I can come up with is:
select round(24*60*60*(julianday('now','localtime')-julianday('now')));
which does produce an offset in seconds, but is cumbersome and non-standard. I'd love a 'current_timestamp with timezone' analogue.
Edit2: At this point I am not sure why I'd bother storing the Julian offset rather than just a second date field representing local time. I guess it saves a few bytes, but that's about it.
datetimeoffset
in SQL Server does though. – Matt Johnson-Pint