How to use timestamp with local time zone in Oracle APEX

In this post I will cover the basics of using a column type timestamp with local time zone in Oracle APEX, this is a simple way that will help us to show date-time information in users timezone.

First will be required to enable the Automatic Time Zone option from Shared Components -> (Globalization) Global Attributes menu:


This will help us to automatically set the time zone each time a user logs in in our application, same result can be achieved calling the procedure APEX_UTIL.SET_SESSION_TIME_ZONE in an Application Process after authentication, the only difference is that you have to provide the time zone with the procedure.

Time zone is set, now we can work on the table, data and page, I will create a simple table with three columns:
  1. Identifier
  2. Timestamp with time zone
  3. Timestamp with local timezone
After that will insert one record to this table setting the SYSTIMESTAMP in both timestamp columns, and then create four Display Only items in the page querying different information, lets take a look on the SQL code.

This is the result in the page.


As you can noticed items Server Date-Time and Server Date-Time from Table show the date-time in the time zone that DB has set, this values will always be the same regardless users time zone, different to items My Current Date-Time and My Current Date-Time from Table that show the date-time in my time zone, if for some reason someone access this page in different time zone those fields will show date-time with the adjustment, giving us the flexibility to provide this information in a customized way for each user time zone.

Comments

Popular posts from this blog

How to show logs in browser console

How to debug your JavaScript web application