> ## Documentation Index
> Fetch the complete documentation index at: https://docs.spojit.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Date & Time

> Format, parse, add/subtract, compare, and convert dates and times.

The Date & Time connector provides operations for working with dates and times: formatting, parsing, timezone conversion, arithmetic, and comparisons.

<Note>No connection required; this utility connector works out of the box.</Note>

## Tools

<AccordionGroup>
  <Accordion title="now: Get current date/time">
    <ParamField body="timezone" type="string">
      Timezone (e.g., `America/New_York`). Defaults to UTC.
    </ParamField>

    <ParamField body="format" type="string">
      Output format. Defaults to ISO 8601.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "timezone": "America/New_York", "format": "YYYY-MM-DD HH:mm:ss" }
    ```

    **Example response:**

    ```json theme={null}
    { "result": "2025-06-15 14:30:22" }
    ```
  </Accordion>

  <Accordion title="format: Format date to string">
    <ParamField body="date" type="string" required>
      Date to format (ISO 8601, Unix timestamp, or parseable string).
    </ParamField>

    <ParamField body="format" type="string" required>
      Output format string (e.g., `YYYY-MM-DD HH:mm:ss`, `DD/MM/YYYY`).
    </ParamField>

    <ParamField body="timezone" type="string">
      Convert to timezone before formatting.
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "date": "2025-03-15T10:30:00Z",
      "format": "dddd, MMMM D, YYYY [at] hh:mm A",
      "timezone": "America/Los_Angeles"
    }
    ```

    **Example response:**

    ```json theme={null}
    { "result": "Saturday, March 15, 2025 at 03:30 AM" }
    ```
  </Accordion>

  <Accordion title="parse: Parse date string">
    Parse a date string to ISO 8601 format.

    <ParamField body="date" type="string" required>
      Date string to parse.
    </ParamField>

    <ParamField body="inputFormat" type="string">
      Expected input format (e.g., `MM/DD/YYYY`).
    </ParamField>

    <ParamField body="timezone" type="string">
      Timezone to interpret the date in. Defaults to UTC.
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "date": "15/03/2025 14:30",
      "inputFormat": "DD/MM/YYYY HH:mm",
      "timezone": "Europe/London"
    }
    ```

    **Example response:**

    ```json theme={null}
    { "iso": "2025-03-15T14:30:00.000Z" }
    ```
  </Accordion>

  <Accordion title="add: Add duration to date">
    <ParamField body="date" type="string" required>
      Starting date.
    </ParamField>

    <ParamField body="value" type="number" required>
      Amount to add (can be negative).
    </ParamField>

    <ParamField body="unit" type="string" required>
      Unit: `year`, `month`, `week`, `day`, `hour`, `minute`, `second`, or `millisecond`.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "date": "2025-01-15T00:00:00Z", "value": 30, "unit": "day" }
    ```

    **Example response:**

    ```json theme={null}
    { "iso": "2025-02-14T00:00:00.000Z" }
    ```
  </Accordion>

  <Accordion title="subtract: Subtract duration from date">
    <ParamField body="date" type="string" required>
      Starting date.
    </ParamField>

    <ParamField body="value" type="number" required>
      Amount to subtract.
    </ParamField>

    <ParamField body="unit" type="string" required>
      Unit: `year`, `month`, `week`, `day`, `hour`, `minute`, `second`, or `millisecond`.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "date": "2025-06-01T12:00:00Z", "value": 3, "unit": "month" }
    ```

    **Example response:**

    ```json theme={null}
    { "iso": "2025-03-01T12:00:00.000Z" }
    ```
  </Accordion>

  <Accordion title="diff: Difference between dates">
    <ParamField body="date1" type="string" required>
      First date.
    </ParamField>

    <ParamField body="date2" type="string" required>
      Second date.
    </ParamField>

    <ParamField body="unit" type="string" default="day">
      Unit for the result.
    </ParamField>

    <ParamField body="precise" type="boolean" default="false">
      Return decimal value.
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "date1": "2025-12-25T00:00:00Z",
      "date2": "2025-01-01T00:00:00Z",
      "unit": "day"
    }
    ```

    **Example response:**

    ```json theme={null}
    { "value": 358, "unit": "day" }
    ```
  </Accordion>

  <Accordion title="timezone: Convert between timezones">
    <ParamField body="date" type="string" required>
      Date to convert.
    </ParamField>

    <ParamField body="from" type="string">
      Source timezone.
    </ParamField>

    <ParamField body="to" type="string" required>
      Target timezone.
    </ParamField>

    <ParamField body="format" type="string">
      Output format.
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "date": "2025-06-15 09:00",
      "from": "America/New_York",
      "to": "Asia/Tokyo",
      "format": "YYYY-MM-DD HH:mm:ss Z"
    }
    ```

    **Example response:**

    ```json theme={null}
    { "result": "2025-06-15 22:00:00 +09:00" }
    ```
  </Accordion>

  <Accordion title="start-of: Start of time period">
    Get the start of a year, month, week, day, hour, minute, or second.

    <ParamField body="date" type="string" required>
      Reference date.
    </ParamField>

    <ParamField body="unit" type="string" required>
      Unit: `year`, `month`, `week`, `day`, `hour`, `minute`, or `second`.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "date": "2025-06-15T14:30:00Z", "unit": "month" }
    ```

    **Example response:**

    ```json theme={null}
    { "iso": "2025-06-01T00:00:00.000Z" }
    ```
  </Accordion>

  <Accordion title="end-of: End of time period">
    Get the end of a year, month, week, day, hour, minute, or second.

    <ParamField body="date" type="string" required>
      Reference date.
    </ParamField>

    <ParamField body="unit" type="string" required>
      Unit: `year`, `month`, `week`, `day`, `hour`, `minute`, or `second`.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "date": "2025-06-15T14:30:00Z", "unit": "month" }
    ```

    **Example response:**

    ```json theme={null}
    { "iso": "2025-06-30T23:59:59.999Z" }
    ```
  </Accordion>

  <Accordion title="is-before: Check if before another date">
    <ParamField body="date" type="string" required>
      Date to check.
    </ParamField>

    <ParamField body="compareTo" type="string" required>
      Date to compare against.
    </ParamField>

    <ParamField body="unit" type="string">
      Comparison granularity.
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "date": "2025-01-15T00:00:00Z",
      "compareTo": "2025-06-01T00:00:00Z",
      "unit": "month"
    }
    ```

    **Example response:**

    ```json theme={null}
    { "result": true }
    ```
  </Accordion>

  <Accordion title="is-after: Check if after another date">
    <ParamField body="date" type="string" required>
      Date to check.
    </ParamField>

    <ParamField body="compareTo" type="string" required>
      Date to compare against.
    </ParamField>

    <ParamField body="unit" type="string">
      Comparison granularity.
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "date": "2025-12-01T00:00:00Z",
      "compareTo": "2025-06-01T00:00:00Z"
    }
    ```

    **Example response:**

    ```json theme={null}
    { "result": true }
    ```
  </Accordion>

  <Accordion title="is-between: Check if between two dates">
    <ParamField body="date" type="string" required>
      Date to check.
    </ParamField>

    <ParamField body="start" type="string" required>
      Start of range.
    </ParamField>

    <ParamField body="end" type="string" required>
      End of range.
    </ParamField>

    <ParamField body="unit" type="string">
      Comparison granularity.
    </ParamField>

    <ParamField body="inclusivity" type="string" default="()">
      Boundary inclusivity: `()`, `[]`, `[)`, or `(]`.
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "date": "2025-06-15T00:00:00Z",
      "start": "2025-06-01T00:00:00Z",
      "end": "2025-06-30T23:59:59Z",
      "inclusivity": "[]"
    }
    ```

    **Example response:**

    ```json theme={null}
    { "result": true }
    ```
  </Accordion>

  <Accordion title="relative: Human-readable relative time">
    Returns strings like "2 hours ago" or "in 3 days".

    <ParamField body="date" type="string" required>
      Date to format.
    </ParamField>

    <ParamField body="from" type="string">
      Reference date (defaults to now).
    </ParamField>

    <ParamField body="withoutSuffix" type="boolean" default="false">
      Omit "ago" or "in" prefix/suffix.
    </ParamField>

    **Example request:**

    ```json theme={null}
    {
      "date": "2025-06-10T00:00:00Z",
      "from": "2025-06-15T00:00:00Z"
    }
    ```

    **Example response:**

    ```json theme={null}
    { "text": "5 days ago" }
    ```
  </Accordion>

  <Accordion title="parts: Extract date components">
    Extract year, month, day, hour, minute, second, etc.

    <ParamField body="date" type="string" required>
      Date to extract from.
    </ParamField>

    <ParamField body="timezone" type="string">
      Timezone for extraction.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "date": "2025-06-15T14:30:00Z", "timezone": "America/New_York" }
    ```

    **Example response:**

    ```json theme={null}
    {
      "year": 2025,
      "month": 6,
      "day": 15,
      "hour": 10,
      "minute": 30,
      "second": 0,
      "millisecond": 0,
      "dayOfWeek": 0,
      "dayOfYear": 166,
      "weekOfYear": 25,
      "quarter": 2,
      "isLeapYear": false,
      "daysInMonth": 30,
      "unix": 1750000200,
      "iso": "2025-06-15T14:30:00.000Z"
    }
    ```
  </Accordion>

  <Accordion title="unix: Convert to/from Unix timestamp">
    <ParamField body="value" type="string | number" required>
      Date string or Unix timestamp.
    </ParamField>

    <ParamField body="toUnix" type="boolean" default="true">
      `true` = date to timestamp, `false` = timestamp to date.
    </ParamField>

    <ParamField body="milliseconds" type="boolean" default="false">
      Use milliseconds instead of seconds.
    </ParamField>

    **Example request:**

    ```json theme={null}
    { "value": "2025-06-15T00:00:00Z", "toUnix": true }
    ```

    **Example response:**

    ```json theme={null}
    { "unix": 1749945600 }
    ```
  </Accordion>

  <Accordion title="list-timezones: List timezone identifiers">
    Returns a list of common timezone identifiers. No parameters required.

    **Example request:**

    ```json theme={null}
    {}
    ```

    **Example response:**

    ```json theme={null}
    {
      "timezones": [
        "UTC",
        "America/New_York",
        "America/Chicago",
        "America/Denver",
        "America/Los_Angeles",
        "Europe/London",
        "Europe/Paris",
        "Asia/Tokyo",
        "Australia/Sydney",
        "Pacific/Auckland"
      ],
      "count": 26
    }
    ```
  </Accordion>
</AccordionGroup>
