# Problem with using {{timestampUtcIso8601}} in request

**URL:** <https://community.postman.com/t/problem-with-using-timestamputciso8601-in-request/15333>\
**Category:** Help Hub\
**Created:** [August 26, 2020, 2:56pm UTC](https://community.postman.com/t/problem-with-using-timestamputciso8601-in-request/15333 "2020-08-26T14:56:02Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![leonardaye](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@leonardaye](https://community.postman.com/u/leonardaye)\
**Post date:** [August 26, 2020, 2:56pm UTC](https://community.postman.com/t/problem-with-using-timestamputciso8601-in-request/15333/1 "2020-08-26T14:56:02Z")

</div>

Hi all  
I need to use the {{timestampUtcIso8601}} in my request to API calls.  
One of the endpoints, the request body looks like this:

```
{
  "Controller": {
    "SerialNumber": "XXXXXXX1111",
    "FirmwareVersion": "3.2.7"
  },
  "PeriodTimeUTC": "{{timestampUtcIso8601}}",
  "UtcOffSet": 60,
  "Meta": {
    "BrandId": 0,
    "AccountNameId": 0
  }
}

```

and this works fine. The PeriodTimeUTC parameter contains the current system time.

However, another endpoint of our API has a body request in this form:

```
{
  "Controller": {
    "SerialNumber": "XXXXXXX1111",
    "FirmwareVersion": "3.2.7"
  },
  "PayLoad": {
    "Data": [
      {
        "Id": 4,
        "UtcOffSet": 120,
        "Count": 2,
        "Markers": {
          "Marker": 1,
          "Start": 3,
          "End": 5,
          "Current": 5
        },
        "Data": "123",
        "PeriodTimeUTC": "{{timestampUtcIso8601}}"
      }
    ]
  }
}

```

and this time, when I submit the request the string {{timestampUtcIso8601}} gets sent as the value of PeriodTimeUTC and not the actual time.

Any idea why this is so? Is it because the latter is inside Data array? If so, is there a way to resolve this?

Any help appreciated.

Cheers

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [August 26, 2020, 3:01pm UTC](https://community.postman.com/t/problem-with-using-timestamputciso8601-in-request/15333/2 "2020-08-26T15:01:44Z")

</div>

Hey @leonardaye

Welcome to the Postman community! ⭐

> [@leonardaye](#):
>
> `{{timestampUtcIso8601}}`

What is that variable referencing? Is that something that you have created in a script somewhere?

---

<div class="post-metadata">

**Author:** ![leonardaye](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@leonardaye](https://community.postman.com/u/leonardaye)\
**Post date:** [August 26, 2020, 3:39pm UTC](https://community.postman.com/t/problem-with-using-timestamputciso8601-in-request/15333/3 "2020-08-26T15:39:27Z")

</div>

No I didn’t create that variable. I thought it was a builtin timestamp function that returns a date in the format YYYY-MM-DD HH:MM:SS.SSSS.

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [August 26, 2020, 3:59pm UTC](https://community.postman.com/t/problem-with-using-timestamputciso8601-in-request/15333/4 "2020-08-26T15:59:54Z")

</div>

I think this is what you’re after `{{$isoTimestamp}}` ?

[https://learning.postman.com/docs/writing-scripts/script-references/variables-list/](https://learning.postman.com/docs/writing-scripts/script-references/variables-list/)

---

<div class="post-metadata">

**Author:** ![leonardaye](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@leonardaye](https://community.postman.com/u/leonardaye)\
**Post date:** [August 27, 2020, 8:28am UTC](https://community.postman.com/t/problem-with-using-timestamputciso8601-in-request/15333/5 "2020-08-27T08:28:04Z")

</div>

Yes, thank you!! That works. 😃

Cheers

---

<div class="post-metadata">

**Author:** ![leonardaye](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@leonardaye](https://community.postman.com/u/leonardaye)\
**Post date:** [September 14, 2020, 10:46am UTC](https://community.postman.com/t/problem-with-using-timestamputciso8601-in-request/15333/6 "2020-09-14T10:46:33Z")

</div>

I have a follow-up question on $isoTimestamp.

Is there a variable in UTC format similar to $randomDateRecent?

In one of our API endpoints, we ingest sensor data from a remote IoT device, containing up to last 7-day’s worth of data. The date field in the request is the initial timestamp when this batch of sensor data was first recorded, along with a series of sensor data, recorded at a fixed time interval.

The API rejects sensor data that is older than 30-days, so I need to set a date that is about 5-7 days in the past from the current date and in UTC format.

Is there a way to create such a date in Postman?

Thanks

---

<div class="post-metadata">

**Author:** ![danny-dainton](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/danny-dainton/32/29401_2.png) [@danny-dainton](https://community.postman.com/u/danny-dainton)\
**Post date:** [September 14, 2020, 11:11am UTC](https://community.postman.com/t/problem-with-using-timestamputciso8601-in-request/15333/7 "2020-09-14T11:11:29Z")

</div>

You can use `moment` to create a timestamp in the past, based on the current time.

```auto
let moment = require('moment'),
    dateInPast = moment().subtract(5, 'days');

pm.environment.set("dateInPast", dateInPast);

```

[https://momentjs.com/docs/#/manipulating/](https://momentjs.com/docs/#/manipulating/)

---

<div class="post-metadata">

**Author:** ![leonardaye](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@leonardaye](https://community.postman.com/u/leonardaye)\
**Post date:** [September 14, 2020, 11:19am UTC](https://community.postman.com/t/problem-with-using-timestamputciso8601-in-request/15333/8 "2020-09-14T11:19:55Z")

</div>

> [@danny-dainton](#):
>
> ```auto
> let moment = require('moment'),
> dateInPast = moment().subtract(5, 'days');
> 
> pm.environment.set("dateInPast", dateInPast);
> 
> ```

Thank you. That worked perfectly!
