PostgreSQL: current_time Function
This PostgreSQL tutorial explains how to use the PostgreSQL current_time function with syntax and examples.
Description
The PostgreSQL current_time function returns the current time with the time zone.
Syntax
The syntax for the current_time function in PostgreSQL is:
current_time( [ precision ] )
Parameters or Arguments
- precision
- Optional. The number of digits to round the fractional seconds to.
Note
- The current_time function will return the current time of day as a 'HH:MM:SS.US+TZ' format.
- Do not put parentheses () after the current_time function when the precision parameter is not specified.
Applies To
The current_time function can be used in the following versions of PostgreSQL:
- PostgreSQL 9.4, PostgreSQL 9.3, PostgreSQL 9.2, PostgreSQL 9.1, PostgreSQL 9.0, PostgreSQL 8.4
Example
Let's look at some PostgreSQL current_time function examples and explore how to use the current_time function in PostgreSQL.
For example:
postgres=# SELECT current_time; timetz -------------------- 20:18:08.586881+00 (1 row) postgres=# SELECT current_time(1); timetz --------------- 20:18:08.6+00 (1 row) postgres=# SELECT current_time(2); timetz --------------- 20:18:08.59+00 (1 row) postgres=# SELECT current_time(3); timetz --------------- 20:18:08.587+00 (1 row)
Advertisements