Skip to Main Content

APEX

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

time zone issue not rendering the correct time

bigmac704Apr 10 2024 — edited Apr 10 2024

Hello

Problem is on a google chromebook is that time zone is set correctly for UTC -05.00) Eastern Time (US & Canada) Adjust for daylight saving time automatically is selected.

I have an Apex 23.2 app for tracking time in and time out for work hours. The strange thing is that some times the correct time is rendered for input in the database other times it is 1 hour difference and minutes are correct. Daylight savings is an issue as well. Now we have tried multiple codes to get this to work 100% of the time. I am currently using:

DECLARE
BEGIN
UPDATE CONTRACT_TIMEKEEPER T
SET T.TIME_OUT = LOCALTIMESTAMP, -- to_timestamp(LOCALTIMESTAMP,'YYYY-MM-DD HH:MI PM')
T.TIME_OUT_UTC = LOCALTIMESTAMP
WHERE T.WORK_DATE = :P3_TODAY
AND T.CONT_ID = :P5_CONT_ID
AND T.POSITION = :P3_POSITION
AND T.TIME_OUT IS NULL
AND T.SCH_ASSIGNED = :P3_SCH;
END;

When we tested the same Chromebook with this code it would clock in correctly, but when it came to clock out the time was 1 hour differece because of the time zone seems to be fliping back and forwoth. We done this with in 10 to 15 mins of clock in and clock out. Why does the time or timezone change when it is suppose to render the machine time zone setting. Is there a different code I can use to set the time correctly in the code instead of using localtimestamp?

I also did this code to see all the differences that are occuring.

select LOCALTIMESTAMP, sysdate, systimestamp, CURRENT_TIMESTAMP, CURRENT_DATE, SESSIONTIMEZONE,
NEW_TIME(LOCALTIMESTAMP, 'EST', 'EDT') AS newtime_test
from dual

Localtimestamp |Sysdate |Systimestamp |Current Timestamp| Current Date
4/10/2024 8:28 |4/10/2024 12:28 |4/10/2024 12:28 |4/10/2024 8:28 | 4/10/2024 8:28

Sessiontimezone| Newtime Test
-04:00" | 4/10/2024 9:28

and i used this code to test other possiblities

SELECT SESSIONTIMEZONE,
TO_CHAR(CURRENT_TIMESTAMP, 'yyyy-mm-dd hh24:mi:ss tzh:tzm tzr tzd') cur_timezone,
FROM DUAL;

Sessiontimezone " -04:00"
cur_timezone 2024-04-10 08:20:48 -04:00 -04:00

Is there a way to code this so it will render this time for the correct time that i need and get the correct time every time someone clocks in or clocks out no matter what?

Thanks

This post has been answered by bigmac704 on Apr 23 2024
Jump to Answer
Comments
Post Details
Added on Apr 10 2024
6 comments
396 views