What's the best-practise way to set [eventName]OccuredAt Timestamp Properties in Ontology Edit Functions

I’m trying to write an ontology edit function to set a property as the current dateTime when the function is called.

My current attempt at doing this is the following:

object.eventOccuredAt = new Date().getTime()

But the linter is complaining at me because you can’t assign a Number to a Timestamp.

Can someone remind me how we can easily convert the current time into a timestamp please?

I think that you actually want to use the following:

import { Timestamp } from "@foundry/functions-api";

...

Timestamp.now()

LocalDate.now().toTimestamp() will result in 00:00 AM UTC on the current date, regardless of the current time. That is probably not what you want!

3 Likes