Critical Moments Docs
Quick StartHomepageAccount
  • Documentation Home
  • What is Critical Moments?
  • Quick Start
  • Concepts Overview
  • Remote Control / Service
    • Host Config on Github Pages
  • Config File Structure
  • Demo App
  • Homepage & Account
  • 📚Guides
    • Mobile App Toolbox: 13 Features Most Apps Need
    • Reduce App Churn with Notifications
    • Improve your App Store Rating
    • Feature Flags Guide
  • ⏰Notifications
    • Intro to Notifications
    • Notifications Spec
    • Smart Delivery
    • Badges
  • 🎯Conditional Targeting
    • Intro to Conditions
    • Built-in Properties
    • Custom Properties
    • Syntax and Operators
    • Conditional Guides
      • Working with Dates
      • Locations and Weather
      • Event and Property History
  • 🎪Events
    • Event Overview
    • Recommended Events
    • Built-In Events
  • 💬Actions / In App Messaging
    • Actions Overview
    • Modals
      • Modal Content Sections
      • Modal Buttons
      • Modal Images
    • Banners
    • Alerts
    • App Reviews
    • Open Link
    • Custom Actions
    • Conditional Actions
    • Triggers
  • 🎨Themes
    • Theme Overview
    • Built In Themes
  • ⛳Feature Flags
    • Feature Flag Guide
    • Conditional Feature Flags
    • Named Conditions Config
  • 🔑Trustless SaaS
  • 👋Support
  • 👩‍💻SDK API Reference
Powered by GitBook
On this page
  • Date Functions
  • Example Conditions With Dates

Was this helpful?

  1. Conditional Targeting
  2. Conditional Guides

Working with Dates

Helper functions for working with dates and times

Last updated 1 year ago

Was this helpful?

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 or formatTime(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

🎯
Now function
Parse date function
Duration function
Format date function
Unix time functions