# Need current Unix time in payload

**URL:** <https://discourse.nodered.org/t/need-current-unix-time-in-payload/74818>\
**Category:** General\
**Tags:** http-request, home-assistant\
**Created:** [6 February 2023 23:36 UTC](https://discourse.nodered.org/t/need-current-unix-time-in-payload/74818 "2023-02-06T23:36:24Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![AnCnoc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ancnoc/32/75683_2.png) [@AnCnoc](https://discourse.nodered.org/u/AnCnoc)\
**Post date:** [6 February 2023 23:36 UTC](https://discourse.nodered.org/t/need-current-unix-time-in-payload/74818/1 "2023-02-06T23:36:24Z")

</div>

Hello, I'm new here so please excuse me if I've jumped the gun by creating a topic for this.

- I need to add a UNIX time to a HTTP URL in order to retrieve data for a given time.  
I have tried to use timestamp but that returns the time in milliseconds rather than seconds and I am no proficient enough in python to do the calculation and then pass the value to the URL.

Long story short, how do I convert a msg.payload which equals timestamp in milliseconds to msg.payload equal to unix time in seconds.

I hope someone can help and I hope this helps others because I have searched online and found a thousand ways to convert from unix time but no way to return to unix time.

Thanks

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [7 February 2023 00:03 UTC](https://discourse.nodered.org/t/need-current-unix-time-in-payload/74818/2 "2023-02-07T00:03:07Z")

</div>

Hi Joe,

Unless I misunderstand the question, I think you can do that with JSONata in a Change node:  
 ![Untitled 3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/3/034429c601dc62bd5a00ea65733e7920ee7f0857.jpeg)

---

<div class="post-metadata">

**Author:** ![AnCnoc](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ancnoc/32/75683_2.png) [@AnCnoc](https://discourse.nodered.org/u/AnCnoc)\
**Post date:** [7 February 2023 01:09 UTC](https://discourse.nodered.org/t/need-current-unix-time-in-payload/74818/3 "2023-02-07T01:09:31Z")

</div>

That’s fantastic, worked perfectly, thanks.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [7 February 2023 07:41 UTC](https://discourse.nodered.org/t/need-current-unix-time-in-payload/74818/4 "2023-02-07T07:41:12Z")

</div>

Possibly better to round rather than floor.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [8 April 2023 07:42 UTC](https://discourse.nodered.org/t/need-current-unix-time-in-payload/74818/5 "2023-04-08T07:42:06Z")

</div>

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