tiempo

addSeconds

Add seconds to a datetime

Add seconds to a datetime.

Signature

function addSeconds(
  input: Temporal.Instant | Temporal.ZonedDateTime,
  seconds: number
): Temporal.ZonedDateTime

Parameters

ParameterTypeDescription
inputTemporal.Instant | Temporal.ZonedDateTimeThe datetime to add seconds to
secondsnumberNumber of seconds to add (can be negative)

Returns

A Temporal.ZonedDateTime with the seconds added.

Examples

import { addSeconds } from '@gobrand/tiempo';

const instant = Temporal.Instant.from('2025-01-20T12:00:00Z');
addSeconds(instant, 90);
// 2025-01-20T12:01:30Z[UTC]

On this page