# Time-stamp json schema

**URL:** <https://community.postman.com/t/time-stamp-json-schema/56343>\
**Category:** Help Hub\
**Tags:** jsonschema\
**Created:** [January 9, 2024, 6:36am UTC](https://community.postman.com/t/time-stamp-json-schema/56343 "2024-01-09T06:36:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![satellite-pilot-5611](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@satellite-pilot-5611](https://community.postman.com/u/satellite-pilot-5611)\
**Post date:** [January 9, 2024, 6:36am UTC](https://community.postman.com/t/time-stamp-json-schema/56343/1 "2024-01-09T06:36:22Z")

</div>

> this is the time-stamp “2024-01-09T06:15:28.384000”  
> I have used the following code in json Schema

```auto

"timestamp": {
                    "type": "string",
                    "format": "date-time"
                },

```

> But it’s not working, I keep on getting the error data validation

---

<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:** [January 9, 2024, 9:43am UTC](https://community.postman.com/t/time-stamp-json-schema/56343/2 "2024-01-09T09:43:07Z")

</div>

Hey @satellite-pilot-5611 👋

Can you share the full schema and and example of the response body that it’s validating against?

Is this is only part that isn’t working as expected? Has it ever worked for you?

* * *

I just created a basic check using the Postman Echo endpoint:

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/4/a/4a66bf6321d0375c87b95d510ec1864bb7fbce46.jpeg)

Using the following schema structure (Yours would be different) for that response worked.

```auto
pm.test("Validate timestamp property in the response", function () {
  var schema = {
    type: "object",
    properties: {
      data: {
        type: "object",
        properties: {
          timestamp: {
            type: "string",
            format: "date-time"
          }
        },
        required: ["timestamp"]
      }
    },
    required: ["data"]
  };

  pm.response.to.have.jsonSchema(schema);
});

```

I ensured it was failing by changing the format of the timestamp value so it would break the validation example in the [JSONSchema docs](https://json-schema.org/understanding-json-schema/reference/string).

 ![image](https://us1.discourse-cdn.com/getpostman/original/3X/c/3/c38eab65acac8d16ead79a8eee3c05645912bb0b.png)

---

<div class="post-metadata">

**Author:** ![satellite-pilot-5611](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@satellite-pilot-5611](https://community.postman.com/u/satellite-pilot-5611)\
**Post date:** [January 9, 2024, 9:55am UTC](https://community.postman.com/t/time-stamp-json-schema/56343/3 "2024-01-09T09:55:21Z")

</div>

yes that’s the only part that’s not working. I saw it in a tutorial by @vdespa.  
It worked there.

That’s the basic schema,

```auto
data:{
    "timestamp": {
                    "type": "string",
                    "format": "date-time"
                },

```

}

---

<div class="post-metadata">

**Author:** ![satellite-pilot-5611](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@satellite-pilot-5611](https://community.postman.com/u/satellite-pilot-5611)\
**Post date:** [January 9, 2024, 9:57am UTC](https://community.postman.com/t/time-stamp-json-schema/56343/4 "2024-01-09T09:57:50Z")

</div>

I think there is the problem of data-format coming from the response. Anyways thanks for the response.

---

<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:** [January 9, 2024, 9:59am UTC](https://community.postman.com/t/time-stamp-json-schema/56343/5 "2024-01-09T09:59:46Z")

</div>

I’m not sure what tutorial that would have been and i’m guessing that @vdespa would have been using an endpoint that returns a different response structure.

I updated my message to show a basic example of this using the Postman Echo service.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/system/32/29796_2.png) [@system](https://community.postman.com/u/system)\
**Post date:** [February 8, 2024, 10:00am UTC](https://community.postman.com/t/time-stamp-json-schema/56343/6 "2024-02-08T10:00:35Z")

</div>

Closed on February 8, 2024, 10:00am UTC

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.
