Cannot seem to find this, does anyone know how to get the current date and time when making a Pack?
Looked at Dates and time samples - Coda Pack SDK as well as tried going through all the attributes from
context but to no avail
const now = new Date();
Ohh, now I feel silly! Never occured to me I could use normal js, thanks!
One important note is that
=Now() is a volatile formula, meaning that Coda regularly recalculates the value. This is what allows it to update on it’s own. Packs can’t create volatile formulas, so a formula that returns
new Date() would output the time when it was first run, but it wouldn’t be automatically recalculated and updated.
Oh that doc is awesome and super helpful, thanks!
Yeah I’ve noticed
=Now() causing a lot of recalculations, it’s what made me try to make my own pack in the first place
You can make
=Now() fire less frequently by using the
DateTimeTruncate formula. For example,
=Now().DateTimeTruncate("minute") will only make it recalculate every minute.
I did a deeper breakdown of this technique in the “How it works” section of this doc:
P.S. - I forgot that the
Now() formula also takes that precision value as an optional parameter, like