---
schema_version: "1"
id: 61baea6d10f0cd0e7d515812194d22b6f0ff2fc5a556178da282f4fe59cbb50e
title: seconds
collection: mulesoft
version: current
locale: en-us
portal_url: https://docs.salesforce.com/mulesoft/current/en-us/dataweave/latest/dw-periods-functions-seconds.md
canonical_url: https://docs.mulesoft.com/dataweave/latest/dw-periods-functions-seconds
source_site: docs.mulesoft.com
content_type: documentation
content_hash: 4250367694b059a0a064c02257f3c1608db117a65d0694cba3722ac73471fd13
description: MuleSoft Documentation Site
release: "2.13"
latest: true
---
---
product: DataWeave
version: 2.13
is-latest-version: true
---

# seconds

> For the full documentation index, see: https://docs.mulesoft.com/llms.txt

## seconds(nSecs: Number): Period

Creates a Period value from the provided number of seconds.

_Introduced in DataWeave version 2.4.0._

### Parameters

<table><colgroup><col> <col></colgroup><thead><tr><th>Name</th><th>Description</th></tr></thead><tbody><tr><td><p><code>nSecs</code></p></td><td><p>The number of seconds as a whole or decimal number. A positive or negative number is valid.</p></td></tr></tbody></table>

### Example

This example shows how `seconds` behaves with different inputs. It adds and subtracts seconds from
DateTime values. It also converts the decimal value `4.555` into the Period format (`PT4.555S`) and
and the whole number `4` into the Period format (`PT4S`)

#### Source

```DataWeave
%dw 2.0
import * from dw::core::Periods
output application/json
---
{
  nextSecond: |2020-10-05T20:22:34.385Z| + seconds(1),
  previousSecond: |2020-10-05T20:22:34.385Z| - seconds(1),
  decimalInputPeriod: seconds(4.555),
  wholeNumberInputPeriod: seconds(4),
  addNegativeValue: seconds(-1) + seconds(2)
}
```

#### Output

```Json
{
  "nextSecond": "2020-10-05T20:22:35.385Z",
  "previousSecond": "2020-10-05T20:22:33.385Z",
  "decimalInputPeriod": "PT4.555S",
  "wholeNumberInputPeriod": "PT4S",
  "addNegativeValue": 1
}
```
