# Using date-fns-tz additional module

**URL:** <https://discourse.nodered.org/t/using-date-fns-tz-additional-module/90435>\
**Category:** General\
**Tags:** function-node\
**Created:** [26 August 2024 00:45 UTC](https://discourse.nodered.org/t/using-date-fns-tz-additional-module/90435 "2024-08-26T00:45:04Z")\
**Posts on this page:** 1\
**Showing post:** 6

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [26 August 2024 14:08 UTC](https://discourse.nodered.org/t/using-date-fns-tz-additional-module/90435/6 "2024-08-26T14:08:49Z")

</div>

Built in moment can do this in a change node.

Alternatively in a function node with

```auto

const d = new Date(msg.payload)
msg.payload = {}

// Get UTC ms since epoch
msg.payload.ts= d.valueOf()

// Get iso time
msg.payload.iso = d.toISOString()

return msg

```

_(Assumes the time to convert is in msg.payload)_

Ref: [Date.prototype.toISOString() - JavaScript | MDN](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date/toISOString)

> [@dangruhn](#):
>
> I **have a local time** value in that I wish to get the timestamp of

I assume you mean an iso string because I associate `timestamp` with the numeric Epoch in JavaScript.

---

_[View the full topic](https://discourse.nodered.org/t/using-date-fns-tz-additional-module/90435)._
