Learn how to use the fromTimestamp function in Notion formulas.

The fromTimestamp() function converts a Unix timestamp into a date.

fromTimestamp(number) number.fromTimestamp()

The Unix timestamp is the number of seconds since January 1, 1970 at 00:00 UTC. It is also known as Unix time or Epoch time.

Note that Notion’s formula editor specifically looks for a Unix millisecond timestamp.

This is important to remember, because fromTimestamp(1656012840) returns January 20, 1970 4:00 AM in Notion (in UTC – it’ll look different based on your timezone).

Unix timestamps are normally expressed in seconds, so most epoch converters would express 1656012840 as June 23, 2022 7:34 PM.

In Notion, you’d need to write fromTimestamp(1656012840000) to get the same date.

You can use this tool to convert human-readable dates to timestamps, and vice-versa:

Epoch Converter – Unix Timestamp Converter
Easy epoch/Unix timestamp converter for computer programmers. Includes epoch explanation and conversion syntax in various programming languages.

Learn more about Unix time:

What Is the Unix Epoch, and How Does Unix Time Work?
Unix stores time as the number of seconds since Jan. 1, 1970. And that means Linux does too. We explain this seemingly odd system, and why doomsday was scheduled for 2038.

Good to know: Notion will always show dates/times created using fromTimestamp() and now in your local time zone. You cannot specify another time zone (you can do this with actual date properties).

Learn more about how Notion handles date objects.

/* Notion will express this date in your local time zone, so it may look different if you try this formula out. */ fromTimestamp(1656012840000) /* Output: June 23, 2022 7:34 PM (UTC) */

The example database below uses timestamp and fromTimestamp() to take in a date and return a different, semi-randomized date.

The “randomness” of this formula is very poor, as the formula has intentionally been kept simple so it can be easily understood.

If you’re curious, here’s an article on pseudorandom number generation that explains the potential pitfalls with using computational algorithms to generate “random” numbers.

Notion does not provide any randomness functions within its formula editor. If you need to generate better random numbers, you should probably create a Notion API integration and utilize a function like JavaScript’s Math.random().

Notion – The all-in-one workspace for your notes, tasks, wikis, and databases.
A new tool that blends your everyday work apps into one. It’s the all-in-one workspace for you and your team
if( minute( prop("Edited") ) % 2 == 0, fromTimestamp( timestamp( prop("Date") ) + toNumber( slice( replaceAll( id(), "\\D", "" ), (timestamp( prop("Edited") ) + 956348) % 7 - 3, 13 ) ) ), fromTimestamp( timestamp( prop("Date") ) - toNumber( slice( replaceAll( id(), "\\D", "" ), (timestamp( prop("Edited") ) + 891327) % 7 - 3, 13 ) ) ) )

To return a seemingly random date, this formula takes the timestamp of the Date property’s date and manipulates it.

First, an if statement determines if the minute of the input date is even or odd using the mod function.

If it is even, then the random date will be later than the input date. If odd, the random date will be earlier than the input date.

The number that is either added to or subtracted from the input date’s timestamp is generated by taking the following steps:

  1. Get the page id using the id function.
  2. Remove all non-numeric characters with replaceAll (which searches for \\D, which is a special regular expression character class meaning “any non-numeric character”).
  3. Slice the resulting string in order to make it smaller. The end index is always 13, but the beginning index is variable. It is determined by (timestamp(prop("Edited")) + 956348) % 7 - 3.
  4. Convert the sliced string to a number using toNumber.

This formula doesn’t use now to determine its output, as the goal is for the date to change whenever the row is edited. Using now would cause the date to change every minute.

Other formula components used in this example:

if – Thomas Frank
timestamp – Thomas Frank
mod – Thomas Frank
add – Thomas Frank
subtract – Thomas Frank
replaceAll – Thomas Frank
slice – Thomas Frank
toNumber – Thomas Frank
equal – Thomas Frank
id – Thomas Frank
About the Author

My name is Thomas Frank, and I'm a Notion-certified writer, YouTuber, and template creator. I've been using Notion since 2018 to organize my personal life and to run my business and YouTube channel. In addition to this formula reference, I've created a free Notion course for beginners and several productivity-focused Notion templates. If you'd like to connect, follow me on Twitter.

🤔 Have an UB Question?

Fill out the form below and I’ll answer as soon as I can! ~Thomas

🤔 Have a Question?

Fill out the form below and I’ll answer as soon as I can! ~Thomas