# Save information to file out with date/time for each information

**URL:** https://discourse.nodered.org/t/save-information-to-file-out-with-date-time-for-each-information/15976
**Category:** General
**Created:** [27 September 2019 06:14 UTC](https://discourse.nodered.org/t/save-information-to-file-out-with-date-time-for-each-information/15976 "2019-09-27T06:14:29Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![iToxace](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/itoxace/32/12508_2.png) [@iToxace](https://discourse.nodered.org/u/iToxace)
#### Post date: [27 September 2019 06:14 UTC](https://discourse.nodered.org/t/save-information-to-file-out-with-date-time-for-each-information/15976/1 "2019-09-27T06:14:29Z")

</div>

Hello I have a problem I would like some help for.  
I have made a flow where when I click on a button it saves the information which my payload gets in a file out. It works perfect except I want it to show date/time for each saved value which in this case is numbers.

example. I click on the button and it saves the number 75. Then instead of just showing 75 in my .txt file I would like it to show 75 08:15 27-09-2019. Just an example. Anyone have any idea how to do that?

---

<div class="post-metadata">

### Author: ![cymplecy](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/cymplecy/32/2773_2.png) [@cymplecy](https://discourse.nodered.org/u/cymplecy)
#### Post date: [27 September 2019 06:23 UTC](https://discourse.nodered.org/t/save-information-to-file-out-with-date-time-for-each-information/15976/2 "2019-09-27T06:23:41Z")

</div>

I use the node-red-contrib-simpletime for stuff like this to access date info

There are many ways of then adding it in - this is one of the simplest using a template node

```auto
[{"id":"4ca03207.2a6e3c","type":"simpletime","z":"4baaf825.5aebd8","name":"","x":440,"y":220,"wires":[["5a62895e.c67b68"]]},{"id":"c444ee44.5e003","type":"inject","z":"4baaf825.5aebd8","name":"","topic":"","payload":"75","payloadType":"num","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":292,"y":220,"wires":[["4ca03207.2a6e3c"]]},{"id":"5a62895e.c67b68","type":"template","z":"4baaf825.5aebd8","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"{{payload}} {{mydate}}","output":"str","x":588,"y":220,"wires":[["2ac473f.63ada8c"]]},{"id":"2ac473f.63ada8c","type":"debug","z":"4baaf825.5aebd8","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":752,"y":220,"wires":[]}]

```

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/2/284935584d5b0ce839d3e2582d19e4f892f3390c.png)

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/1/1d86c1dd72fb08d4f438aeb93d2a291d656cea5b.png)

---

<div class="post-metadata">

### Author: ![drmibell](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/drmibell/32/8424_2.png) [@drmibell](https://discourse.nodered.org/u/drmibell)
#### Post date: [1 October 2019 15:05 UTC](https://discourse.nodered.org/t/save-information-to-file-out-with-date-time-for-each-information/15976/3 "2019-10-01T15:05:03Z")

</div>

As always, NR gives you lots of ways to do things. Possibly the most simple, using only core nodes, would be something like this.

```auto
[{"id":"c4310b2a.540fb8","type":"inject","z":"bef81aa8.c22888","name":"","topic":"","payload":"75","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":150,"y":120,"wires":[["e656e38f.c43398"]]},{"id":"e656e38f.c43398","type":"change","z":"bef81aa8.c22888","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload & ' ' & $now()","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":300,"y":120,"wires":[["43cb85be.b7a08c"]]},{"id":"43cb85be.b7a08c","type":"debug","z":"bef81aa8.c22888","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":470,"y":120,"wires":[]}]

```

 ![flow](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/7/753a1937c81a61689de946c6c1929dd89c37c966.jpeg)

If you are not happy with the date format given by the JSONata `$now` function, you will have to do a bit more work.

---

<div class="post-metadata">

### Author: ![shrickus](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/shrickus/32/517_2.png) [@shrickus](https://discourse.nodered.org/u/shrickus)
#### Post date: [2 October 2019 14:32 UTC](https://discourse.nodered.org/t/save-information-to-file-out-with-date-time-for-each-information/15976/4 "2019-10-02T14:32:40Z")

</div>

I daresay it sounds like you are moving toward generating either entries in a spreadsheet, or better yet records in a database. The possibilities of post-processing and querying the data later will be much better with either of these persistence tools, as compared to a text file.

If you are interested in learning about either of those solutions, there are lots posts on the forum with examples -- and if you get stuck, lots of members in this community that can help. Have fun!
