This Oracle tutorial explains how to use the Oracle/PLSQL LOCALTIMESTAMP function with syntax and examples.
The Oracle/PLSQL LOCALTIMESTAMP function returns the current date and time in the time zone of the current SQL session as set by the ALTER SESSION command. It returns a TIMESTAMP value.
The syntax for the LOCALTIMESTAMP function in Oracle/PLSQL is:
LOCALTIMESTAMP
There are no parameters or arguments for the LOCALTIMESTAMP function.
The LOCALTIMESTAMP function returns a TIMESTAMP value.
The LOCALTIMESTAMP function can be used in the following versions of Oracle/PLSQL:
Let's look at some Oracle LOCALTIMESTAMP function examples and explore how to use the LOCALTIMESTAMP function in Oracle/PLSQL.
For example:
If the following ALTER SESSION command was issued:
ALTER SESSION SET TIME_ZONE = '-7:0';
And then the following SQL statement was executed:
select LOCALTIMESTAMP
from dual;
You might get the following result:
10-Sep-05 10.58.24 PM
You then modified the session time zone with the following ALTER SESSION command:
ALTER SESSION SET TIME_ZONE = '-2:0';
And then the following SQL statement was executed:
select LOCALTIMESTAMP
from dual;
You would now get the following result:
10-Sep-05 03.58.24 AM
The session time zone value has changed from -7:0 to -2:0, causing the LOCALTIMESTAMP function to return the current date and time as a value 5 hours ahead.