Improved date variables
We've added a new date and time variable to help you send out messages faster and not have to open the calendar.
You can now format dates in almost any way you need, get a future or past date, or compare today’s date to another date. Everything is available in more than 90 languages.
The new variable is {{moment}}
, and using it without any options will display today’s date.
Formatting
Format today’s date by using {{moment format="YYYY MM"}}
. Format values are compatible with Moment.js formatting.
Here are some examples:
{{moment format="MMMM"}}
will display the current month.{{moment format="dddd"}}
will insert the day of the week.{{moment format="L"}}
will display today’s date in local format (eg. 07/01/2020).
Manipulating dates
You can manipulate dates by adding or subtracting hours, days, months, or years.
To add a couple of days to today’s date, use {{moment add="7;days"}}
. You can add anything from milliseconds to years. The number of days and the type of duration needs to be separated by a semicolon.
Like adding days, to subtract days use {{moment subtract="7;days"}}
.
You can also get the start or end of a period of time. For example, if you need next Monday’s date, you can use {{moment add="1;week" startOf="isoWeek"}}
.
To get next Friday's date you would use {{moment subtract="2;days" endOf="isoWeek"}}
.
Relative to a different date
If you need to compare today’s date to another specific date, we’ve got you covered.
To get the amount of time to or from a different date, you can use fromNow
or toNow
.
- Using
{{moment "2020-07-20" fromNow=true}}
will display something like 5 days. {{moment "2020-07-10" toNow=""}}
will display something similar to 4 days ago.
More languages
All these features are available in a lot of different languages. You can switch language by using {{moment locale="fr"}}
.
See our Date and time variables page in the Help Center, for more examples and information.
Thoughts or questions about this post? Need some help?
Get in touch at support@briskine.com