localtime

A function returning the time the current transaction started

localtime is a system function returning the time at which the current transaction started, without the time zone.

localtime was added in PostgreSQL 7.3.

Usage

localtime → time
localtime ( integer ) → time

The optional integer parameter determines to how many digits the fractional digits in the seconds field should be rounded.

For an equivalent function returning a timestamp with time zone, see current_time.

Change history

Examples

Basic usage example for localtime:

postgres=# SELECT localtime;
    localtime    
-----------------
 17:51:15.083027
(1 row)

Speciftying the precision:

postgres=# SELECT localtime(0);
 localtime 
-----------
 17:56:36
(1 row)

postgres=# SELECT localtime(3);
  localtime   
--------------
 17:56:37.896
(1 row)

A precision greater than 6 will be rounded down:

postgres=# SELECT localtime(7);
WARNING:  TIME(7) precision reduced to maximum allowed, 6
    localtime    
-----------------
 17:57:36.350601
(1 row)

Categories

Date and time, System function

See also

localtimestamp, current_time