PostgreSQL timeofday() Function

The PostgreSQL timeofday() function returns a string representing the timestamp of when this function was executed. Two executions of timeofday() may return different values.

The timeofday() function is like the clock_timestamp() function, but instead of returning a string, clock_timestamp() returns a timestamp value.

timeofday() Syntax

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

timeofday() -> TEXT


The PostgreSQL timeofday() function does not have any parameters.

Return value

The PostgreSQL timeofday() function returns a string that represents the system date and time when this function was executed, with time zone information.

timeofday() Examples

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

SELECT timeofday();
 Tue May 17 08:41:37.562608 2022 CST

During statement execution, multiple timeofday() functions may return different values, as in the following example:

-[ RECORD 1 ]----------------------------------
timeofday | Tue May 17 08:42:03.575992 2022 CST
pg_sleep  |
timeofday | Tue May 17 08:42:04.580394 2022 CST

Here we can see that the timestamp returned by the second timeofday() is 1 second later than the first one, because the pg_sleep(1) function pauses execution for 1 second.