Skip to main content

Date and Time Utilities

Calculate, compare, and format timestamps within your workflows using Torq’s built-in date and time utility steps.

Updated this week

Torq’s Date and Time utilities perform common date and time operations, such as calculating durations, converting formats, retrieving current dates, and comparing timestamps.

Supported date/time layouts

All Date and Time utilities in Torq use ISO 8601 by default (YYYY-MM-DDTHH:MM:SSZ) to keep timestamps consistent across integrations and systems. They also support Go (Golang) time layouts, as shown below.

Layout

Meaning

2006-01-02T15:04:05Z07:00

ISO-8601 / RFC3339 with timezone

Mon Jan 2 15:04:05 MST 2006

Full Go style with weekday + timezone

Mon Jan 2 15:04:05 2006

Same as above, without timezone

02 Jan 06 15:04 MST

Day-month-yy + time + timezone name

02 Jan 06 15:04 -0700

Day-month-yy + time + numeric timezone offset

Monday, 02-Jan-06 15:04:05 MST

Full weekday name + timezone

Mon, 02 Jan 2006 15:04:05 -0700

RFC1123-like header/email date

3:04PM

12-hour time with AM/PM

15:04:05

24-hour time with seconds

20060102

Compact numeric date YYYYMMDD

2006-01-02

Date only YYYY-MM-DD

2006-01-02 15:04:05

Date + 24-hour time

2006-02-01 15:04:05

Year-day-month + time

1136214245

Unix epoch seconds value (not a layout). Use a layout above to format it.

Custom

Customized date/time format. Replace the parts you want to display and keep any separators exactly as you want them to appear.

Get Date

Returns the current date in the defined format. You can optionally set an offset (to move forward or backward in time) and specify a time zone.

Input

{
"Date_Format": "%Y-%m-%dT%H:%M:%S",
"Offset": "-24h",
"Time_Zone": "America/New_York"
}

Output

2022-06-14T14:30:45

If working across multiple regions:

  • Always specify the Time_Zone parameter explicitly to avoid UTC/local discrepancies.

  • Use clear UTC offsets when parsing or converting dates (e.g., +00:00, 05:00).

Convert Date

Converts a date from one format to another.

Input

{
"Date": "2006-01-02T15:04:05Z",
"Current_Date_Format_Layout": "2006-01-02T15:04:05Z07:00",
"New_Date_Format_Layout": "Mon Jan 2 15:04:05 MST 2006"
}

Output

Mon Jan 2 15:04:05 MST 2006

When using Convert Date, ensure the Current Date Format Layout exactly matches the format of your input date string. A mismatch will cause the conversion to fail or produce invalid results.

Calculate End Date

Calculates the end date by adding a specified duration to a given start date.

Input

{
"Start_Date": "2023-01-01T00:00:00Z",
"Duration": "48h"
}

Output

2023-01-03T00:00:00Z

Calculate Calendar Days

Calculates the number of calendar days between two dates.

Input

{
"Start_Date": "2023-01-01T00:00:00Z",
"End_Date": "2023-01-10T00:00:00Z"
}

Output

9

Calculate Time Duration

Calculates the time elapsed from a given date to the current time and returns the result in the specified format.

Input

{
"Date_Format": "%Y-%m-%dT%H:%M:%S",
"Date": "2006-08-29T23:59:11"
}

Output

138422h29m13.895503549s

Check DST Status

Verifies whether Daylight Saving Time (DST) is currently in effect for a given region at the time of execution. Supported regions: EU, USA, IST, and AUS. If DST is in effect, the step returns true.

Input

{
"Region": "USA"
}

Output

true

Use case: Convert Date

Automatically tag newly created cases as Weekday or Weekend using the Date and Time utility. This workflow helps teams quickly identify cases created outside of business hours.

For a detailed implementation, refer to the full workflow template available in Torq.

  1. Define workflow parameters: Set up the timezone (Europe/London)

  2. Find the hour and the day of the week for a case’s creation time:

    1. Use the Parallel Executions step to run simultaneously two Convert Date utility instances to:

      • Find hour in local TZ by extracting the hour (00–23) from the case creation timestamp. It converts the case’s creation date ({{ $.event.cases.current.created_at }}) into just the hour portion, adjusted for the defined timezone.

      • Find day in local TZ by extracting the day of the week (0 to 6) from the same creation timestamp. The %w returns a number where:

        • 0 = Sunday

        • 1 = Monday

        • 6 = Saturday

  3. Continue with the next steps: After extracting the local hour and day using Convert Date in parallel, the workflow evaluates whether the case was created during working hours or on a weekend. It then applies the appropriate tag (e.g., Weekday or Weekend) and can trigger follow-up actions such as notifying the relevant team or updating the case in Torq.

Use case: Get Date

AppSec or SOC teams often need a fast way to answer: “Do we have any packages, projects, or cloud assets affected by this CVE?” This workflow lets analysts run a CVE lookup from Slack, automatically search the connected security platforms across all relevant organizations for matching findings, and open or update a Jira issue with the latest exposure details.

The Get Date utility defines the search window used by those platform queries, ensuring results reflect recent exposure and making the evidence consistent and reproducible in Slack and Jira.

For a detailed implementation, refer to the full workflow template available in Torq.

  1. Trigger CVE search from Slack:

    1. Configure a Slack trigger to run on messages that include cve-search.

    2. Extract the first CVE ID from the message text.

    3. If no CVE is found, reply in-thread with usage instructions and stop the workflow.

  2. Get time window using Get Date utility: Use the Parallel Executions step to run two Get Date utility instances:

    • Get date now: Add a Get Date utility step to capture the current timestamp. Store the output for later use as the end time for your security platform searches.

    • Get date 1 month ago: Add a second Get Date utility step with TIME_AGO: 30d to capture the timestamp from 30 days prior. Store the output for later use as the start time for your security platform searches.

    • Store both outputs and use them as the search window for your security platform queries.

  3. Continue with the next steps: After defining the time window with Get Date, the workflow lists all available organizations across the connected security platforms, loops through each one, and searches for findings matching the extracted CVE within the last 30 days. It then normalizes and aggregates the results, posts a CSV summary back to the originating Slack thread (or a “no exposure found” notice if empty), and creates or updates a Jira issue for that CVE.

Did this answer your question?