# Date & Time

> The current moment and today, as Luxon DateTime values.

Source: https://docs.sommatic.ai/en/expressions/reference/date-time/

Each example was run against the deployed expression engine over the [example context](#example-context) at the end of the page.

## `$now`

Variable · `DateTime` · Source: `Luxon · DateTime`

```javascript
$now
```

A [Luxon](https://docs.sommatic.ai/en/expressions/luxon/) `DateTime` taken when the node starts resolving its configuration: every expression of one node sees the same moment. It is in the server's time zone, so set the zone you need before formatting or comparing calendar days.

In a pure field, `$now` keeps its type and the node receives a `DateTime`; in a mixed field it is inserted as quoted JSON text. Format it yourself (`toISO()`, `toFormat(…)`) whenever the result goes into text.

### Members

| Signature | Type | Description |
| --- | --- | --- |
| `$now.toISO()` | `string` | ISO 8601 date and time with the zone offset. |
| `$now.toISODate()` | `string` | The date only: `yyyy-MM-dd`. |
| `$now.toFormat(format)` | `string` | Text with Luxon tokens: `yyyy` year, `LL` month, `dd` day, `HH` hour, `mm` minutes, `ss` seconds. |
| `$now.toMillis()` | `number` | Milliseconds since 1970-01-01 UTC. |
| `$now.toSeconds()` | `number` | Seconds since 1970-01-01 UTC, with decimals. |
| `$now.setZone(zone)` | `DateTime` | The same moment seen in another IANA zone, such as `America/Bogota` or `UTC`. |
| `$now.plus({ days, hours, minutes… })` | `DateTime` | A later moment. |
| `$now.minus({ days, hours, minutes… })` | `DateTime` | An earlier moment. |
| `$now.startOf(unit)` | `DateTime` | The start of the `year`, `month`, `week`, `day`, `hour` or `minute`. |
| `$now.endOf(unit)` | `DateTime` | The last millisecond of that unit. |
| `$now.diff(other, unit)` | `Duration` | The time between two dates; read it with `.as('days')` or `.toObject()`. |
| `$now.weekday` | `number` | Day of the week, 1 (Monday) to 7 (Sunday). Also `year`, `month`, `day`, `hour`, `minute`. |
| `$now.constructor` | `DateTime class` | The `DateTime` class itself, to parse dates: `$now.constructor.fromISO(text)`, `.fromFormat(text, format)`, `.fromMillis(ms)`. |

### Examples

```javascript
{{ $now.toISO() }}
```

Result (string):

```json
"2026-11-26T14:30:00.000Z"
```

```javascript
{{ $now.setZone('America/Bogota').toFormat('yyyy-LL-dd HH:mm') }}
```

Result (string):

```json
"2026-11-26 09:30"
```

```javascript
{{ $now.plus({ days: 3 }).toISODate() }}
```

Result (string):

```json
"2026-11-29"
```

```javascript
{{ $now.toMillis() }}
```

Result (number):

```json
1795703400000
```

Hours since a date that arrived as ISO text.

```javascript
{{ $now.diff($now.constructor.fromISO($json.body.created_at), 'hours').as('hours') }}
```

Result (number):

```json
29.25
```

Is it the weekend in Bogotá?

```javascript
{{ $now.setZone('America/Bogota').weekday >= 6 }}
```

Result (boolean):

```json
false
```

A bare $now in a mixed field is inserted as quoted JSON.

```javascript
Sent at {{ $now }}
```

Result (string):

```json
"Sent at \"2026-11-26T14:30:00.000Z\""
```

### Notes

- The full list of DateTime methods, getters and static constructors is in the [Luxon reference](https://docs.sommatic.ai/en/expressions/luxon/).
- `DateTime` is not a global name: reach the class through `$now.constructor`.

In JSONata: Not usable: $$now arrives as an object whose methods JSONata cannot call. Use the JSONata functions $now() and $fromMillis().

## `$today`

Variable · `DateTime` · Source: `Luxon · DateTime`

```javascript
$today
```

Midnight of the current day in the server's time zone: `$now.startOf('day')`. To get the start of the day in another zone, use `$now.setZone(zone).startOf('day')`; converting `$today` would give midnight of the server's day, seen from that zone.

### Examples

```javascript
{{ $today.toISODate() }}
```

Result (string):

```json
"2026-11-26"
```

A due date 30 days from today.

```javascript
{{ $today.plus({ days: 30 }).toISODate() }}
```

Result (string):

```json
"2026-12-26"
```

The start of today in another zone.

```javascript
{{ $now.setZone('America/Bogota').startOf('day').toISO() }}
```

Result (string):

```json
"2026-11-26T00:00:00.000-05:00"
```

In JSONata: Not usable from JSONata, for the same reason as $now.

## Example context

The examples run over this data: the input of the current node (`$json`), the nodes that already ran (`$(…)`), the ids of the run and the current node. The clock is fixed at `2026-11-26T14:30:00.000Z` and the server zone is UTC, so `$now` and `$today` give the same values on every page.

```json
{
  "$json": {
    "body": {
      "order_id": "ord_1042",
      "email": "ana.perez@example.com",
      "customer": {
        "name": "Ana Pérez",
        "segment": "gold"
      },
      "priority": "",
      "items": [
        {
          "sku": "A-100",
          "qty": 2,
          "price": 10.5
        },
        {
          "sku": "B-200",
          "qty": 0,
          "price": 4
        },
        {
          "sku": "C-300",
          "qty": 1,
          "price": 25
        }
      ],
      "tags": [
        "new",
        "web",
        "new"
      ],
      "created_at": "2026-11-25T09:15:00Z"
    },
    "headers": {
      "content-type": "application/json"
    },
    "query": {},
    "method": "POST"
  },
  "nodes": {
    "Webhook Receiver": "= $json",
    "Normalize input": {
      "correlation_id": "c-7f3a",
      "channel": "web"
    },
    "Classify": {
      "label": "billing",
      "confidence": 0.92
    }
  },
  "run": {
    "$flow_instance_result_id": "fir-xxxx",
    "$flow_instance_id": "fi-xxxx",
    "$flow_definition_id": "fd-xxxx",
    "$flow_version_id": "fv-xxxx",
    "$flow_slug": "order-intake"
  },
  "node": {
    "node_id": "node-notify",
    "label": "Notify customer"
  }
}
```

The examples of a chained workflow run over a second context: a workflow started by `workflow.chain`, whose `workflow.trigger` node is labelled `Chain Entry Point`.

```json
{
  "$json": {
    "order_id": "ord_1042",
    "customer_email": "ana.perez@example.com",
    "amount": 46,
    "chain_context": {
      "caller_flow_definition_id": "fd-caller-xxxx",
      "caller_flow_instance_id": "fi-caller-xxxx",
      "caller_flow_slug": "order-intake",
      "caller_node_id": "node-chain-billing",
      "correlation_id": "chain-7Hq2Lw9sKd3pXa1mZr4t",
      "root_flow_instance_result_id": "fir-root-xxxx"
    }
  },
  "run": {
    "$flow_instance_result_id": "fir-hop-xxxx",
    "$flow_instance_id": "fi-hop-xxxx",
    "$flow_definition_id": "fd-billing-xxxx",
    "$flow_version_id": "fv-billing-xxxx",
    "$flow_slug": "billing-review",
    "$input": {
      "data": {
        "order_id": "ord_1042",
        "customer_email": "ana.perez@example.com",
        "amount": 46
      },
      "chain_context": {
        "caller_flow_definition_id": "fd-caller-xxxx",
        "caller_flow_instance_id": "fi-caller-xxxx",
        "caller_flow_slug": "order-intake",
        "caller_node_id": "node-chain-billing",
        "correlation_id": "chain-7Hq2Lw9sKd3pXa1mZr4t",
        "root_flow_instance_result_id": "fir-root-xxxx"
      }
    }
  },
  "node": {
    "node_id": "node-create-task",
    "label": "Create review task"
  }
}
```

Examples run against the orchestrator at commit 31e874b.
