The LOCALTIMESTAMP function returns the current date in the time zone of the current session. The return type is TIMESTAMP. This function and the CURRENT_TIMESTAMP function return different data types. The CURRENT_TIMESTAMP function returns a value of the TIMESTAMP WITH TIME ZONE data type.
Syntax
LOCALTIMESTAMP (timestamp_precision)
Parameters
| Parameter | Description |
|---|---|
| timestamp_precision | The precision of fractional seconds. The value ranges from 0 to 9, and the default value is 6. |
Return type
TIMESTAMP data type
Examples
The following examples show the results that the LOCALTIMESTAMP function returns in different session time zones.
Set the current time zone to the UTC-5 time zone:
ALTER SESSION SET TIME_ZONE = '-05:00';
Execute the following statement to call the function:
SELECT LOCALTIMESTAMP FROM DUAL;
The following query result is returned:
+----------------------------+
| LOCALTIMESTAMP |
+----------------------------+
| 2020-03-08 02:30:20.062104 |
+----------------------------+
Change the current time zone to the UTC+8 time zone and change the precision of fractional seconds to 3:
ALTER SESSION SET TIME_ZONE = '+08:00';
Execute the following statement to call the function:
SELECT LOCALTIMESTAMP(3) FROM DUAL;
The following query result is returned:
+-------------------------+
| LOCALTIMESTAMP(3) |
+-------------------------+
| 2020-03-08 15:30:54.500 |
+-------------------------+