# ServerTime in Function Node formated for InfluxDB2 (RFC3339)

**URL:** <https://discourse.nodered.org/t/servertime-in-function-node-formated-for-influxdb2-rfc3339/72079>\
**Category:** General\
**Created:** [12 December 2022 14:28 UTC](https://discourse.nodered.org/t/servertime-in-function-node-formated-for-influxdb2-rfc3339/72079 "2022-12-12T14:28:24Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Starfoxfs](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/starfoxfs/32/69119_2.png) [@Starfoxfs](https://discourse.nodered.org/u/Starfoxfs)\
**Post date:** [12 December 2022 14:28 UTC](https://discourse.nodered.org/t/servertime-in-function-node-formated-for-influxdb2-rfc3339/72079/1 "2022-12-12T14:28:24Z")

</div>

Hi,

how can i format the ServerTime (Now) for InfluxDB2 ?

It needs the RFC3339 Format.

```auto
(new Date()).toISOString()

```

won´t work, i get an Error from InfluxDB Node "bad Timestamp"

---

<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:** [12 December 2022 16:11 UTC](https://discourse.nodered.org/t/servertime-in-function-node-formated-for-influxdb2-rfc3339/72079/2 "2022-12-12T16:11:31Z")

</div>

Isnt InfluxDB timestamps in micro seconds unless you tell it otherwise?

Try using `Date.now() * 1000)` instead of passing a string.

---

<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:** [12 December 2022 18:25 UTC](https://discourse.nodered.org/t/servertime-in-function-node-formated-for-influxdb2-rfc3339/72079/3 "2022-12-12T18:25:06Z")

</div>

Did you try just passing the influx node the Date object?

Also, don't forget that if you are passing in the current time then you generally don't need to do that, influx will default to the current time.

---

<div class="post-metadata">

**Author:** ![Starfoxfs](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/starfoxfs/32/69119_2.png) [@Starfoxfs](https://discourse.nodered.org/u/Starfoxfs)\
**Post date:** [13 December 2022 08:20 UTC](https://discourse.nodered.org/t/servertime-in-function-node-formated-for-influxdb2-rfc3339/72079/4 "2022-12-13T08:20:27Z")

</div>

Yes i just passed it, but before i used InlfuxDB 1.8, now it´s Version 2.5 with Flux language, and the Flux \_time \_start and \_stop is more variable then before.

So i want to use my own Timestamp in a variable, not the one of InfluxDB

---

<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:** [13 December 2022 16:04 UTC](https://discourse.nodered.org/t/servertime-in-function-node-formated-for-influxdb2-rfc3339/72079/5 "2022-12-13T16:04:26Z")

</div>

OK, I was just checking in case you were not aware of the options. I have not moved to Influx 2 yet.

---

<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:** [27 December 2022 16:04 UTC](https://discourse.nodered.org/t/servertime-in-function-node-formated-for-influxdb2-rfc3339/72079/6 "2022-12-27T16:04:53Z")

</div>

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