PostgreSQL -CLOCK_TIMESTAMP
The clock_timestamp()
function is used to retrieve the current timestamp as of the current transaction’s start time. It returns a timestamp with time zone that represents the exact time when the current transaction began.
Here’s how you can use the clock_timestamp()
function in PostgreSQL:
SELECT clock_timestamp();
The above SQL statement will return the current timestamp, including the time zone information, for the moment when the current transaction was initiated.
For example, if you execute SELECT clock_timestamp();
at different points within a transaction, you may get different timestamps reflecting the time when that specific part of the transaction began.
This function is useful when you need to measure the duration of a specific operation within a transaction or when you want to ensure that you’re working with a consistent timestamp throughout the transaction, regardless of any time zone changes or system clock adjustments.