# Protobuf timestamp representation

**URL:** <https://community.postman.com/t/protobuf-timestamp-representation/48775>\
**Category:** Help Hub\
**Tags:** grpc\
**Created:** [June 21, 2023, 12:14pm UTC](https://community.postman.com/t/protobuf-timestamp-representation/48775 "2023-06-21T12:14:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![avionics-observer-29](https://avatars.discourse-cdn.com/v4/letter/a/e95f7d/32.png) [@avionics-observer-29](https://community.postman.com/u/avionics-observer-29)\
**Post date:** [June 21, 2023, 12:14pm UTC](https://community.postman.com/t/protobuf-timestamp-representation/48775/1 "2023-06-21T12:14:01Z")

</div>

Hello!

I’m using google/protobuf/timestamp.proto in my protobuf objects.

I’d expect the response to be something like:

{  
“created\_at”: “2022-06-29T02:08:07.100Z”,  
}

but instead I get the Timestamp response of something like (ignore actual dates, they wont match):

{  
“created\_at”: {  
“seconds”: “1656466246”,  
“nanos”: 85158000  
}  
}

Can I customize this behaviour?

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [June 21, 2023, 5:02pm UTC](https://community.postman.com/t/protobuf-timestamp-representation/48775/2 "2023-06-21T17:02:15Z")

</div>

You can’t customise it directly as that will be down to the API, but you can use the Tests tab to manipulate the format.

You can use something like the following to get a timestamp, and then use the moment library (which is included in the Postman sandbox) to format it however you want.

```auto
function toDateTime(secs) {
    var t = new Date(Date.UTC(1970, 0, 1)); // Epoch
    t.setUTCSeconds(secs);
    return t;
}

console.log(toDateTime(1656466246)); // Wed Jun 29 2022 02:30:46 GMT+0100 (British Summer Time)

```

I don’t really get the nanos part so don’t know if that is meant to be part of the calculation somehow.

---

<div class="post-metadata">

**Author:** ![michaelderekjones](https://sea2.discourse-cdn.com/getpostman/user_avatar/community.postman.com/michaelderekjones/32/14819_2.png) [@michaelderekjones](https://community.postman.com/u/michaelderekjones)\
**Post date:** [June 22, 2023, 10:46am UTC](https://community.postman.com/t/protobuf-timestamp-representation/48775/3 "2023-06-22T10:46:56Z")

</div>

> [@avionics-observer-29](#):
>
> 1656466246

I think this can also be converted using the following…

```auto
let date = "1656466246"

let toISOstring = (new Date(date * 1000)).toISOString();
console.log(toISOstring); // 2022-06-29T01:30:46.000Z

// using moment to format the date

var moment = require('moment');
var formattedDate2 = moment(toISOstring).format("DDMMYYYY");
console.log(formattedDate2); // 29062022

```
