# Working with Dates

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

* [Now function](/conditional-targeting/syntax-and-operators.md#now)
* [Parse date function](/conditional-targeting/syntax-and-operators.md#date-str-format-timezone)
* [Duration function](/conditional-targeting/syntax-and-operators.md#duration-str)
* [Format date function](/conditional-targeting/syntax-and-operators.md#formattime-timestamp-format-timezone)
* [Unix time functions](/conditional-targeting/syntax-and-operators.md#unixtimeseconds-int-unixtimemilliseconds-int-unixtimenanoseconds-int-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')`&#x20;
* 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`&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.criticalmoments.io/conditional-targeting/conditional-guides/working-with-dates.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
