PostgreSQL now() Function

The PostgreSQL now() function returns the system date and time when the current transaction started.

The PostgreSQL now() function is equivalent to transaction_timestamp() and current_timestamp().

now() Syntax

Here is the syntax of the PostgreSQL now() function:

now() -> timestamp

Parameters

The PostgreSQL now() function does not require any parameters.

Return value

The PostgreSQL now() function returns a date and time with time zone information, which is the system date and time when the current transaction started.

That is, all now() functions in a transaction return the same value, that is different from clock_timestamp().

now() Examples

This example shows how to use the PostgreSQL now() function to get the current date and time.

SELECT now();
              now
-------------------------------
 2022-05-15 22:17:34.819513+03

The now() function returns the time when the current transaction started, not the time when the function was executed. See the example below:

SELECT
    now(),
    pg_sleep(1),
    now();
-[ RECORD 1 ]---------------------------
now      | 2022-05-15 22:18:31.076406+03
pg_sleep |
now      | 2022-05-15 22:18:31.076406+03

Here, even though we use pg_sleep(1) to pause execution for 1 second between the two now() functions, the values returned by both now() functions are still the same.