Add_time

Adds a specific type of offset to an existing datetime object.

Syntax

datetime add_time(datetime $startDate, number|string $offset, string $offsetType)

Adds the $offset of the specific $offsetType to the original $startDate.

Parameters

$startDate: The datetime object that should have the $offset added to it.
$offset: The number that defines how much offset that should be added to the $startDate-
$offsetType: The type of offset that should be added to the $startDate. The different types available are:

  • t (ticks)
  • ms (milliseconds)
  • s (seconds)
  • min (minutes)
  • h (hours)
  • d (days)
  • m (months)
  • y (years)

Example

{
    "startDate": "2023-01-01T00:00:00.00Z",
    "offset": 30,
    "offsetType": "d"
}
{
    addedTime: add_time(startDate, offset, offsetType),
    formattedTime: format($.addedTime, 'dd-MM-yyyy', 'en-GB')
}
{
    "addedTime": "2023-01-31T00:00:00Z",
    "formattedTime": "31-01-2023"
}

This example shows how to add 30 days to the date 1st of January 2023. The start date is of the type datetime, the offset is a number, and the offset type is a string identical to one of the types (in this case “days”) listed above.