The PostgreSQL LOCALTIME
function returns the current time at which the current transaction starts.
Syntax
The syntax of the LOCALTIME
function is as follows:
1 | LOCALTIME(precision) |
Arguments
The LOCALTIME
function takes one optional argument:
1) precision
The precision
argument specifies fractional seconds precision of the second field.
If you omit the argument, it defaults to 6.
Return Value
The LOCALTIME
function returns a TIME
value that represents the time at which the current transaction starts.
Examples
The following query illustrates how to get the time of the current transaction:
1 | SELECT LOCALTIME; |
Here is the result:
1 2 3 4 | time ----------------- 09:52:20.751278 (1 row) |
The get the time with a specified fractional seconds precision, you use the following statement:
1 | SELECT LOCALTIME(2); |
The result is:
1 2 3 4 | time ------------- 09:53:10.74 (1 row) |
Remarks
Noted that the LOCATIME
function returns a TIME
value without time zone while the CURRENT_TIME
function returns a TIME
with time zone.
In this tutorial, you have learned how to use the PostgreSQL LOCALTIME
function to get the time at which the current transaction starts.