PostgreSQL current_time Function

The PostgreSQL current_time function returns the system time with time zone information in the format HH:MM:SS.ssssss{+|-}ZZ.

current_time Syntax

Here is the syntax of the PostgreSQL current_time function:

current_time -> TIME WITH TIME ZONE

or

current_time(precision INTEGER) -> TIME WITH TIME ZONE

Parameters

precision

Required. An integer indicating the number of fractional seconds.

Return value

The PostgreSQL current_time function returns the system time with time zone information in the format HH:MM:SS.ssssss{+|-}ZZ.

Note that the current_time function returns the time when the statement in which it was executed started, not the time when the function was executed.

current_time Examples

This example shows how to use the PostgreSQL current_time function to get the current system date.

SELECT current_time;
    current_time
--------------------
 20:37:44.688689+03

You can specify the number of fractional seconds with a parameter. The following example returns a current time value with 2 fractional seconds:

SELECT current_time(2);
  current_time
----------------
 20:38:57.61+03

The current_time function returns the time when the statement in which it was executed started, not the time when the function was executed.

SELECT current_time, pg_sleep(1), current_time;
-[ RECORD 1 ]+-------------------
current_time | 20:40:09.088746+08
pg_sleep     |
current_time | 20:40:09.088746+08

We can see that even though we used the pg_sleep(1) function to pause for 1 second between the two current_time functions, the two current_time functions still returned the same value.