GetTime

Retrieves the current date and time.

javascript · Common Scripts

Details

IDGetTime
Languagejavascript
From Version5.0.0
TagsUtility

README

Retrieves the current date and time.

Script Data


Name Description
Script Type javascript
Tags Utility
Cortex XSOAR Version 5.0.0

Inputs


Argument Name Description
date The date to use in the object.
dateFormat The date format for the result. Can be ISO/GMT/UTC/Locale/Date/Year/Month/Day/DayInWeek/Hours.
Note that the response will start from 0. For example, if the current month is October
(the 10th month) the result will be 9.
Note:
In Cortex XSOAR versions 6.11 or later, or 8.1.0 or later, the time format returned when UTC or GMT is given has changed.
Instead of ‘Wed Jan 18 2023 12:59:12 GMT+0000 (UTC)’, The output will be ‘Wed, 18 Jan 2023 15:59:12 GMT’.
contextKey Prefix the keys in the context for the results.
minutesAgo Will subtract minutesAgo minutes from current time.
hoursAgo Will subtract hoursAgo hours from current time.
daysAgo Will subtract daysAgo days from current time.
monthsAgo Will subtract monthsAgo months from current time.
yearsAgo Will subtract yearsAgo years from current time.

Outputs


Path Description Type
TimeNowUnix Number of milliseconds since 1970/01/01. Number
TimeNow Current time. String
commonfields:
  id: GetTime
  version: -1
name: GetTime
script: ''
type: javascript
tags:
- Utility
comment: |
  Retrieves the current date and time.
enabled: true
args:
- name: date
  default: true
  description: The date to use in the object.
- name: dateFormat
  description: |-
    The date format for the result. Can be ISO/GMT/UTC/Locale/Date/Year/Month/Day/DayInWeek/Hours.
    Note that the response will start from 0. For example, if the current month is October
    (the 10th month) the result will be 9.
    Note:
    In Cortex XSOAR versions 6.11 or later, or 8.1.0 or later, the time format returned when UTC or GMT is given has changed.
    Instead of 'Wed Jan 18 2023 12:59:12 GMT+0000 (UTC)', The output will be 'Wed, 18 Jan 2023 15:59:12 GMT'.
- name: contextKey
  description: Prefix the keys in the context for the results.
- name: minutesAgo
  description: Will subtract minutesAgo minutes from current time.
- name: hoursAgo
  description: Will subtract hoursAgo hours from current time.
- name: daysAgo
  description: Will subtract daysAgo days from current time.
- name: monthsAgo
  description: Will subtract monthsAgo months from current time.
- name: yearsAgo
  description: Will subtract yearsAgo years from current time.
outputs:
- contextPath: TimeNowUnix
  description: Number of milliseconds since 1970/01/01.
  type: Number
- contextPath: TimeNow
  description: Current time.
  type: String
scripttarget: 0
tests:
- GetTime-Test
- GetTime-ObjectVsStringTest
fromversion: 5.0.0