Jeffrey Kemp Jeffrey Kemp - 7 months ago 45
SQL Question

Convert a date/time from UTC to session time zone

My program receives timestamps in UTC, e.g.

Tue, 31 May 2016 11:43:47 UTC
. How do I convert them to a timestamp in the session's current timezone?


First convert the string to a timestamp with timezone (use the correct function). To show the result in your local (session) time zone, use the "AT LOCAL" clause.

select to_timestamp_tz('Tue, 31 May 2016 19:43:47 UTC', 
                                'Dy, dd Mon yyyy hh24:mi:ss tzr') at local from dual;

Result (using my front-end settings for displaying timestamp with timezone - yours may be different):