The now()
function returns the current date and time in your local timezone. now()
accepts no arguments.
now()
Code language: JavaScript (javascript)
Notion sets your timezone automatically using your system/OS timezone.
If you need to return the current date without the time, use today instead.
now()
, today, fromTimestamp, and parseDate are the only functions that will allow you to add a true date object into a formula without pulling from a Date property. Of these, parseDate()
is the best for creating date objects for dates other than the current date.
Example Formula
now() /* Output: June 23, 2022 12:30 PM (at time of writing) */
Code language: JavaScript (javascript)
Get the Current Date Without the Time
Use the following formula to remove the current time from now()
:
now()
.formatDate("YYYY-MM-DD")
.parseDate()
Code language: JavaScript (javascript)
Here’s why you might want to do this:
When doing date math operations (e.g. dateAdd/dateSubtract) in Notion, now()
can cause problems due to its inclusion of the current time.
Take this formula as an example:
/* Assume Date's current value is June 30, and now() is June 23 */
dateBetween(prop("Date"), now(), "weeks")
Code language: JavaScript (javascript)
If it’s currently June 23, and the value of the Date property is June 30, then this formula should return 1
. June 30 is 7 days out from June 23, hence one week.
However, this formula will actually return 0
because the values that are implicitly being compared are June 23, 2022 1:35 PM
and June 30, 2022 12:00 AM
.
As a result, the gap between the two dates is not 7 full days.
In Notion, dates without times given a default (and normally hidden) time of 00:00
, aka 12:00 AM
.
However, the now()
function always includes the time. There’s no argument that allows you to customize its output so that it only returns the date.
To do that, you need to use the formula shown at the top of this section: now().formatDate("YYYY-MM-DD").parseDate()
.
As no time is specified, the result is a date object that contains the current date with a time of 00:00
.
Example Database
The example database below shows how you can “hard-code” dates into a Notion formula using the now()
function along with dateAdd and dateSubtract. The Date property outputs a date that matches the choices set in the Month and Day properties.
View and Duplicate Database
“Date” Property Formula
Code language: JavaScript (javascript)
This example builds on the “hard-code” examples shown above.
Instead of hard-coding a specific date, the formula allows user input via a Select property (Month) and a Number property (Day). This allows the user to select their own specific date, which is still not tied to any particular year. The chosen month/day date will always contain the current year.
To set the month, the replace function is used (many times) to replace the chosen month’s text string with its corresponding month value (0-11). This replacement number is then turned into an actual number via the toNumber function.