PostgreSQL Tutorial PostgreSQL Advanced PostgreSQL Database Account Management PostgreSQL References
PostgreSQL Tutorial PostgreSQL Advanced PostgreSQL Database Account Management PostgreSQL References

PostgreSQL NOW() Function



The PostgreSQL NOW() function returns the current date and time with the time zone. This function returns the current date as a 'YYYY-MM-DD HH:MM:SS.US+TZ' format.

Syntax

NOW()

Parameters

No parameter is required.

Return Value

Returns the current date as a 'YYYY-MM-DD HH:MM:SS.US+TZ' format.

Example 1:

The example below shows the usage of NOW() function.

SELECT NOW();
Result: '2022-01-24 16:30:28.642838+00'

Example 2:

Consider a database table called EmployeeLogin with the following records:

EmpIDNameLogin Stamp
1John2019-10-25 09:20:38.123456+00
2Marry2019-10-25 09:21:05.654321+00
3Jo2019-10-25 09:24:35.122456+00
4Kim2019-10-25 09:25:24.604599+00
5Ramesh2019-10-25 09:27:16.443368+00

To insert a new record in this table, the following statement can be used.

INSERT INTO EmployeeLogin 
VALUES (6, 'Suresh', NOW());

-- see the result
SELECT * FROM EmployeeLogin;

This will produce a result similar to:

EmpIDNameLogin Stamp
1John2019-10-25 09:20:38.123456+00
2Marry2019-10-25 09:21:05.654321+00
3Jo2019-10-25 09:24:35.122456+00
4Kim2019-10-25 09:25:24.604599+00
5Ramesh2019-10-25 09:27:16.443368+00
6Suresh2019-10-25 09:28:19.642838+00

❮ PostgreSQL Functions