As of version 20.2, the Automatic Time Zone setting in APEX presents two significant challenges:
1. It won’t account for changes in local time zones (such as EST to EDT)
2. It won’t work with public applications that do deep linking.
Anton solves both these issues by bypassing the ‘Automatic Time Zone encoding’ APEX feature. See his alternative in this week’s episode.
Detailed instructions on the solution
Create Page 0: Global Page Region and Item
Create a Region named TZ Region
Note: if you don’t want this region and item to show, set the Template to “Inline Dialog”
Create an item P0_TZ
Item Type: Text Field Warn on Unsaved Changes: Ignore
Note: if you would like this to be a Time Zone selector follow the instruction in the last section.
Create Page 0 Dynamic Action: Set Session Time Zone
Create Dynamic Action as shown:
Create True Action 1: Set Value
JavaScript Expression
Intl.DateTimeFormat().resolvedOptions().timeZone;
Create True Action 2: Execute Server-side Code
PL/SQL Code
begin
apex_util.set_session_time_zone( P_TIME_ZONE => :P0_TZ);
end;
Create True Action 3: Execute JavaScript Code
JavaScript Code
location.reload();
Change to be a Time Zone Selector
Ensure that TZ Region and P0_TZ are visible on pages
Change P0_TZ to be a Select List
Set the List of Values to be a SQL Query
select distinct tzname d, tzname r
from V$TIMEZONE_NAMES
order by 1
Duplicate the Page Load Dynamic Action and make changes to it
Change the Name to “Change Time Zone” Change the “When” settings Change the Server-side Condition Delete the “Set Value” true action
View Past Episodes
Full episode list on YouTube here.