Autumn Offers - hours only!Up to 80% off on all courses and bundles.-Close
Dealing with dates
Working with time
Date and time data types in PostgreSQL
Extracting dates and times
Timezone conversion
Format date and time
Current date and time data
44. The CURRENT_TIMESTAMP and NOW() functions


Now we'll learn how to get the current date and time.

PostgreSQL actually has several functions you can use to get the current date and time. Each function returns different details.

Let's start with the simplest function: NOW(). It returns the current date and time with time zone. Here's how you use it:


It's very simple, right?

The CURRENT_TIMESTAMP function works exactly like NOW(). You don't need parentheses with this function, just the name will do:


This returns a date and time with fractional seconds and includes the time zone information.

Why do we have two functions that do the same thing? CURRENT_TIMESTAMP follows the ANSI SQL standard; NOW() is the PostgreSQL version.


Run the template query to check the current date and time with the time zone.