On this page
Sommatic Docs
Open portal

Date & Time

Manipulates date and time values, offering formatting, calculations, and current time generation.

View as Markdown
Open in
Data Available data.datetime Version 1.0.0 Execution: sync

Gets the current time, formats a date, adds time to a date or computes the difference between two dates with Luxon, and adds the value as result to the incoming payload.

This utility does not rely on external services and uses the 'luxon' library for robust handling of timezones and formats.

Operations:

  • Now: Returns the current date/time in the specified timezone.
  • Format: Converts a date string into a specific format pattern.
  • Add: Adds time (minutes, days, etc.) to a given date.
  • Diff: Calculates the difference between two dates in a specific unit.

Use Cases:

  • Generating timestamps for DB records.
  • Calculating "Due Date" (Now + 7 Days).
  • Formatting dates for email templates (e.g., "Jan 01, 2024").

How it works

  1. Resolves the config with these defaults: operation now, format ISO, amount 0, unit hours, timezone UTC.
  2. now: the current time in timezone, as ISO 8601.
  3. format: parses value as ISO 8601, converts it to timezone and returns ISO 8601, or the Luxon pattern in format (for example yyyy-MM-dd HH:mm).
  4. add: parses value, converts it to timezone, adds amount (converted to a number, negative allowed) in unit and returns ISO 8601. format is not applied.
  5. diff: returns value minus to_value (default now) in unit as a number that can have decimals; positive when value is later. timezone is not used.
  6. Returns the incoming payload plus result through out, and repeats the value in meta.result.

In a workflow

The node as it appears in a workflow file (draft_nodes[]), and the envelope of a successful run.

{
  "node_id": "node-due-date",
  "label": "Compute due date",
  "operator_slug": "data.datetime",
  "operator_version": "1.0.0",
  "config": {
    "operation": "add",
    "value": "{{ $json.created_at }}",
    "amount": 3,
    "unit": "days",
    "timezone": "America/Bogota"
  }
}

Configuration

operation string Required

The date operation to perform.

Default: now

Allowed values: nowformatadddiff

value string Optional Accepts expressions

The source date (ISO string). Required for Format, Add, and Diff.

Shown when: operation = format | add | diff

format string Optional

The output format pattern (e.g., `yyyy-MM-dd HH:mm`). standard Luxon tokens.

Default: ISO

Shown when: operation = format

amount integer Optional

Number of units to add (can be negative).

Default: 0

Shown when: operation = add

unit string Optional

Default: hours

Allowed values: minuteshoursdaysweeksmonthsyears

Shown when: operation = add | diff

to_value string Optional Accepts expressions

The second date for "Diff" operations.

Shown when: operation = diff

timezone string Optional

Target timezone for the operation.

Default: UTC

Its configuration shows the shared execution settings, but this node does not apply retries (retryOnFail, maxTries) yet. continueOnFail is not applied by any node.

Behaviour in the code

What the implementation does with these keys beyond what the schema says.

value
Only ISO 8601 strings are parsed (2026-11-26, 2026-11-26T15:00:00Z). Other formats such as 26/11/2026 or epoch numbers fail.
timezone
With an unknown zone, now returns result: null through out instead of failing.
unit
Passed to Luxon as is, so other Luxon units such as seconds also work.

Output ports

out default

The operation succeeded. result is a string, or a number for diff.

Data
{
  "order_id": "ord_123",
  "created_at": "2026-11-26T15:00:00.000Z",
  "result": "2026-11-29T10:00:00.000-05:00"
}
error

A date is invalid or the operation is unknown.

Data
{
  "ok": false,
  "errors": [
    "Datetime Error: Invalid date: 26/11/2026 - unparsable"
  ],
  "port": "error"
}

In expressions

What a later node can read from this node's output with $("Date & Time").item.json.<path> (write your node's label instead of Date & Time). Editor marks the paths the workflow editor suggests under Previous Nodes (the output contract); Worker marks the paths the worker really returns through out, from the output shown in Ports.

ExpressionEditorWorker
$("Date & Time").item.json.resultstring | number= "2026-11-29T10:00:00.000-05:00"The resulting date string or calculated difference.
$("Date & Time").item.json.order_idstringNot suggested by the editor= "ord_123"—
$("Date & Time").item.json.created_atstringNot suggested by the editor= "2026-11-26T15:00:00.000Z"—

— Worker: The worker returns it but the editor does not suggest it: write it by hand. Keys inside objects can depend on your data or configuration (for example one key per label).

Errors

Message Port Cause and fix
Datetime Error: Invalid date: <value> - <reason> error format received a value that is not ISO 8601 (reason unparsable) or an unknown timezone (reason unsupported zone).
Datetime Error: Invalid date: <value> error add received an invalid value or timezone.
Datetime Error: Invalid dates for diff error value or to_value is not ISO 8601.
Datetime Error: Unknown operation: <operation> error operation is not now, format, add or diff.

Input contract

value string Optional
to_value string Optional

Output contract

result string | number Optional

The resulting date string or calculated difference.

Contracts (JSON Schema)

The definition exactly as the orchestrator declares it. All is the whole *.definition.js; compare it with the sections above to spot differences between the documentation and the schema. Use it to validate a node before you publish.

{
  "slug": "data.datetime",
  "name": "Date & Time",
  "category": "data",
  "version": "1.0.0",
  "description": "Manipulates date and time values, offering formatting, calculations, and current time generation.\n\n  This utility does not rely on external services and uses the 'luxon' library for robust handling of timezones and formats.\n\n  **Operations:**\n  - **Now:** Returns the current date/time in the specified timezone.\n  - **Format:** Converts a date string into a specific format pattern.\n  - **Add:** Adds time (minutes, days, etc.) to a given date.\n  - **Diff:** Calculates the difference between two dates in a specific unit.\n\n  **Use Cases:**\n  - Generating timestamps for DB records.\n  - Calculating \"Due Date\" (Now + 7 Days).\n  - Formatting dates for email templates (e.g., \"Jan 01, 2024\").",
  "capabilities": [
    "utils",
    "date",
    "time",
    "luxon"
  ],
  "config_schema": {
    "type": "object",
    "properties": {
      "operation": {
        "type": "string",
        "enum": [
          "now",
          "format",
          "add",
          "diff"
        ],
        "default": "now",
        "title": "Operation",
        "description": "The date operation to perform."
      },
      "value": {
        "type": "string",
        "title": "Input Date",
        "description": "The source date (ISO string). Required for Format, Add, and Diff.",
        "format": "expression",
        "displayOptions": {
          "show": {
            "operation": [
              "format",
              "add",
              "diff"
            ]
          }
        }
      },
      "format": {
        "type": "string",
        "title": "Format Pattern",
        "default": "ISO",
        "description": "The output format pattern (e.g., `yyyy-MM-dd HH:mm`). standard Luxon tokens.",
        "displayOptions": {
          "show": {
            "operation": [
              "format"
            ]
          }
        }
      },
      "amount": {
        "type": "integer",
        "default": 0,
        "title": "Amount to Add",
        "description": "Number of units to add (can be negative).",
        "displayOptions": {
          "show": {
            "operation": [
              "add"
            ]
          }
        }
      },
      "unit": {
        "type": "string",
        "enum": [
          "minutes",
          "hours",
          "days",
          "weeks",
          "months",
          "years"
        ],
        "default": "hours",
        "title": "Unit",
        "displayOptions": {
          "show": {
            "operation": [
              "add",
              "diff"
            ]
          }
        }
      },
      "to_value": {
        "type": "string",
        "title": "Compare Date",
        "description": "The second date for \"Diff\" operations.",
        "format": "expression",
        "displayOptions": {
          "show": {
            "operation": [
              "diff"
            ]
          }
        }
      },
      "timezone": {
        "type": "string",
        "default": "UTC",
        "ui_widget": "timezone_picker",
        "title": "Timezone",
        "description": "Target timezone for the operation."
      },
      "execution": {
        "type": "object",
        "title": "Execution Settings",
        "properties": {
          "alwaysOutputData": {
            "type": "boolean",
            "title": "Always Output Data",
            "description": "Always output data, even on error (if configured).",
            "default": false
          },
          "retryOnFail": {
            "type": "boolean",
            "title": "Retry On Fail",
            "description": "Retry the execution if it fails.",
            "default": false
          },
          "maxTries": {
            "type": "integer",
            "title": "Max Retries",
            "description": "Number of retries.",
            "default": 3,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "waitBetweenTries": {
            "type": "integer",
            "title": "Wait Between Retries (ms)",
            "default": 1000,
            "displayOptions": {
              "show": {
                "retryOnFail": [
                  true
                ]
              }
            }
          },
          "continueOnFail": {
            "type": "boolean",
            "title": "Continue On Fail",
            "description": "Do not crash workflow on error.",
            "default": false
          },
          "timeout_ms": {
            "type": "integer",
            "title": "Timeout (ms)",
            "description": "Max execution time for this node before it is killed, in milliseconds. Honored by long-running operators (e.g. OCR/extraction, inline code). Default 300000 (5 min).",
            "default": 300000
          }
        }
      }
    },
    "required": [
      "operation"
    ]
  },
  "input_contract_schema": {
    "type": "object",
    "properties": {
      "value": {
        "type": "string"
      },
      "to_value": {
        "type": "string"
      }
    }
  },
  "output_contract_schema": {
    "type": "object",
    "properties": {
      "result": {
        "type": [
          "string",
          "number"
        ],
        "description": "The resulting date string or calculated difference."
      }
    }
  },
  "ports": [
    {
      "port_id": "out",
      "label": "Output",
      "is_default": true,
      "description": "Operation successful"
    },
    {
      "port_id": "error",
      "label": "Error",
      "description": "Invalid date or format"
    }
  ],
  "execution_mode": "sync",
  "tags": [
    "date",
    "time",
    "utils"
  ],
  "is_stateful": false,
  "publisher": {
    "identity": "org_link_loom",
    "profile": {
      "name": "Link Loom",
      "verified": true,
      "url": "https://me.veripass.com/link-loom",
      "logo_url": null
    }
  }
}

Execution

Execution
sync
Stateful
No
Retries (retryOnFail)
No
Capabilities
utilsdatetimeluxon
Tags
datetimeutils

Notes and limits

  • An existing result key in the payload is overwritten.
  • When the envelope has no data (or data is falsy), the engine stores the whole envelope as the node output: on error the next node receives { ok: false, errors: [...], port: "error" } as its payload.

Reviewed against the orchestrator code · 31e874b · 2026-11-26

Install agent tools

Give your coding agent the official Sommatic AI docs: skills, the docs MCP server and Markdown pages, so it never has to scrape the site.

Skills only. They do not update by themselves; run it again to refresh.

npx skills add https://docs.sommatic.ai
How agents read these docs