Working with Dates
Helper functions for working with dates and times
Critical Moments provides a set of helper functions to make working with conditions strings with dates easy! Well, at least as easy as working with dates can be...
Date Functions
Example Conditions With Dates
Did the user downloaded this app in the last 12 hours?
app_install_date > now() - duration('12h')
Did the user install the app more than 30 days ago?
app_install_date < now() - duration('720h')
Did the user downloaded the app before a given absolute datetime?
app_install_date > date('2023-01-25T12:00:00+00:00')
Is the current device time after a date, in the user's local timezone? For example: launching new feature at midnight local time.
now() > date('2024-04-05', date_format, 'Local')
Is the time between 10pm PST and 11pm PST on a given date? Example: you're taking your service down for maintenance and what to show a "we'll be back online soon" message:
now() > date('2024-01-15T22:00:00-08:00') && now() < date('2024-01-15T23:00:00-08:00')
Was the app was installed before a given unix timestamp?
app_install_date < unixTimeMilliseconds(1136189045000)
Is it currently a Wednesday in the user's local timezone
formatTime(now(), 'dow') == 3
orformatTime(now(), 'dow_long') == 'Wednesday'
Is it currently the evening (5pm-9pm) in the user's local timzeone
formatTime(now(), 'hod') >= 17 || formatTime(now(), 'hod') <= 21
Last updated