The timestamp()
function converts a date argument into its corresponding Unix timestamp (also known as Unix Time or Epoch Time), which is a number.
timestamp(date)
Code language: JavaScript (javascript)
The Unix timestamp is the number of seconds since January 1, 1970 at 00:00 UTC.
Notion’s timestamp()
function specifically outputs a millisecond timestamp.
You can use this site to convert human-readable dates to Unix timestamps, or vice-versa:
Good to know: Since Notion returns a millisecond timestamp, pasting the timestamp for very early dates (e.g. January 8, 1970) can cause conversion tools like the website above to return an incorrect date.
To account for this, remove the final three zeroes (000) from Notion’s timestamp before pasting into a conversion tool.
Example Formula
timestamp(now()) // Output: 1656012120000 (will change with the value of now()
Code language: JavaScript (javascript)
Example Database
The example database below uses the timestamp()
function to determine which of two dates is the later one.
View and Duplicate Database
“Later Date” Property Formula
// Compressed
if(timestamp(prop("Date 1")) == timestamp(prop("Date 2")),"Date 1 and Date 2 are the same.",if(timestamp(prop("Date 1")) > timestamp(prop("Date 2")),"Date 1 is later than Date 2.","Date 2 is later than Date 1."))
// Expanded
if(
timestamp(
prop("Date 1")
) == timestamp(
prop("Date 2")
),
"Date 1 and Date 2 are the same.",
if(
timestamp(
prop("Date 1")
) > timestamp(
prop("Date 2")
),
"Date 1 is later than Date 2.",
"Date 2 is later than Date 1."
)
)
Code language: JavaScript (javascript)
This formula uses a nested if-statement to first check if the timestamp values of the two dates are equal. If they are, the formula returns, “Date 1 and Date 2 are the same.”
If not, the next block checks to see if Date 1’s timestamp is larger than Date 2’s timestamp.
Depending on the result of this comparison, the formula will return, “Date 1 is later than Date 2,” or “Date 2 is later than Date 1.”