How to obtain the current timestamp in a PostgreSQL database?

In the pg database, you can use the CURRENT_TIMESTAMP function to get the current timestamp. This function returns the current date and time, including time zone information. You can directly use this function in an SQL query to retrieve the current timestamp, for example:

SELECT CURRENT_TIMESTAMP;

This will return a timestamp in a format similar to the following:

2021-08-24 09:30:00.123456+03

You can also use the now() function to get the current timestamp, it has the same function as the CURRENT_TIMESTAMP function, for example:

SELECT now();

Regardless of which function is used, it is possible to obtain the current timestamp.

bannerAds