PostgreSQL – LOCALTIMESTAMP
The localtimestamp
function is used to retrieve the current timestamp according to the time zone setting of your database session. This function returns the current date and time as a timestamp with time zone.
Here’s how you can use localtimestamp
in PostgreSQL:
SELECT localtimestamp;
The above SQL statement will return the current timestamp based on the time zone set for your database session.
For example, if your database session is configured to use the “US/Eastern” time zone, executing SELECT localtimestamp;
will return a timestamp with the current date and time in the Eastern Time Zone.
The output will look something like this:
localtimestamp
-------------------------------
2023-09-21 14:30:00.123456-04 (1 row)
The result of localtimestamp
is affected by the time zone setting of your PostgreSQL session, so the actual timestamp returned may vary based on the session’s time zone configuration.