Problem with using {{timestampUtcIso8601}} in request

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.


Hey @leonardaye

Welcome to the Postman community! :star:

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

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.

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

Yes, thank you!! That works. :smiley:


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?


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

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

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

Thank you. That worked perfectly!

1 Like