Purpose
LOCALTIMESTAMP() returns the current date in the time zone of the current session in a value of the TIMESTAMP data type.
CURRENT_TIMESTAMP differs from this function in that CURRENT_TIMESTAMP returns a value of the TIMESTAMP WITH TIME ZONE data type.
Syntax
LOCALTIMESTAMP [(timestamp_precision)]
Parameters
timestamp_precision specifies the fractional seconds precision. It is an integer in the range of [0, 9]. This parameter is optional. Its default value is 6.
Return type
The return type is TIMESTAMP.
Examples
The following example sets the current time zone to GMT-5 and uses
LOCALTIMESTAMPto return the current date.obclient> ALTER SESSION SET TIME_ZONE = '-05:00'; Query OK, 0 rows affected obclient> SELECT LOCALTIMESTAMP FROM DUAL; +------------------------------+ | LOCALTIMESTAMP | +------------------------------+ | 17-NOV-21 04.36.28.557316 AM | +------------------------------+ 1 row in setThe following example sets the current time zone to GMT+8 with the fractional seconds precision of
3decimal places, and usesLOCALTIMESTAMPto return the current date.obclient> ALTER SESSION SET TIME_ZONE = '+08:00'; Query OK, 0 rows affected obclient> SELECT LOCALTIMESTAMP(3) FROM DUAL; +---------------------------+ | LOCALTIMESTAMP(3) | +---------------------------+ | 17-NOV-21 05.38.12.839 PM | +---------------------------+ 1 row in set