now
PG 8.0+→ timestamp with time zoneReturns the current date and time at the start of the current transaction.
Signature
now ( ) → timestamp with time zoneExamples
SELECT now();2025-03-07 14:23:01.123456+00SELECT now()::date;2025-03-07SELECT now() - interval '7 days';7 days agoINSERT INTO audit_log (event, recorded_at) VALUES ('login', now());Row inserted with transaction start timeUsing `now()` inside a loop or long migration to record step timing is misleading — it always returns the same transaction start time, so all recorded times will be identical.
✓ Instead: Use `clock_timestamp()` when you need the actual wall-clock time at each point within a transaction.
`now()` returns the transaction start time and does NOT advance during a long transaction. Use `clock_timestamp()` if you need the actual wall-clock time at each function call — important for timing loops or progress logging.
SELECT clock_timestamp() - now() AS time_in_transaction;Elapsed time since transaction began