# Issue with node-red-contrib-simpletime

**URL:** <https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752>\
**Category:** General\
**Created:** [13 December 2018 10:22 UTC](https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752 "2018-12-13T10:22:05Z")\
**Posts on this page:** 14\
**Page:** 1

<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:** [13 December 2018 10:22 UTC](https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752/1 "2018-12-13T10:22:05Z")

</div>

@Paul-Reed

I'm having a slight issue

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/b/b36e48c730a529994752096f26951b61916ca7e1.png)  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/d/d027c0838336dc86ece78d96fe25548a40974256.png)

```auto
[{"id":"8bc823cb.6b9ca","type":"inject","z":"48a2710e.b4384","name":"","topic":"","payload":"something ","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":540,"y":980,"wires":[["889dd4cc.e917e8"]]},{"id":"dd5ac8c7.8182b8","type":"debug","z":"48a2710e.b4384","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1230,"y":980,"wires":[]},{"id":"889dd4cc.e917e8","type":"simpletime","z":"48a2710e.b4384","name":"","x":730,"y":980,"wires":[["66f435ae.25292c","2d78ca24.7df136"]]},{"id":"a9329680.1a7bb8","type":"change","z":"48a2710e.b4384","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload & myrawdate","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":1060,"wires":[["dd5ac8c7.8182b8"]]},{"id":"66f435ae.25292c","type":"change","z":"48a2710e.b4384","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"myrawdate","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":980,"wires":[["dd5ac8c7.8182b8"]]},{"id":"2d78ca24.7df136","type":"delay","z":"48a2710e.b4384","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":740,"y":1060,"wires":[["a9329680.1a7bb8"]]}]

```

When I trigger the flow - I get an expanded date time string instead of the documented myrawdate format  
But in the delayed change node path (which concats the payload with myrawdate )- I get the expected format but with extra "" marks

I'm very confused as to what is going on!

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [13 December 2018 10:34 UTC](https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752/2 "2018-12-13T10:34:45Z")

</div>

Have you tried clicking on the top one in the debug?  
I think it recognises it as a Date and therefore “translates” it for display

---

<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:** [13 December 2018 11:10 UTC](https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752/3 "2018-12-13T11:10:16Z")

</div>

Aah - yes - that explains the 1st one- ta 🙂

But still got those extra quotes in the delayed one

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [13 December 2018 17:27 UTC](https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752/4 "2018-12-13T17:27:22Z")

</div>

> [@cymplecy](#):
>
> But in the delayed change node path (which concats the payload with myrawdate )- I get the expected format but with extra "" marks

I've just tried your flow, and the output from Simpletime is correct: `myrawdate: "2018-12-13T17:10:06.809Z"`, so the error appears to be in your change node jsonata expression in the way it's trying to combine the two strings.

Sorry, can't help further with jsonata - it's the black arts as far as I'm concerned!!  
Probably one for guru Steve @shrickus

---

<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:** [13 December 2018 17:50 UTC](https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752/5 "2018-12-13T17:50:59Z")

</div>

There's black arts going on all over the place with this one!

Just tried a simpe function node - and that transforms the msg.myrawdate as well

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

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

```auto
[{"id":"8bc823cb.6b9ca","type":"inject","z":"48a2710e.b4384","name":"","topic":"","payload":"something ","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":540,"y":980,"wires":[["889dd4cc.e917e8"]]},{"id":"dd5ac8c7.8182b8","type":"debug","z":"48a2710e.b4384","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":1230,"y":980,"wires":[]},{"id":"889dd4cc.e917e8","type":"simpletime","z":"48a2710e.b4384","name":"","x":730,"y":980,"wires":[["66f435ae.25292c","2d78ca24.7df136","96c00ce3.9f343"]]},{"id":"a9329680.1a7bb8","type":"change","z":"48a2710e.b4384","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload & myrawdate","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":1060,"wires":[["dd5ac8c7.8182b8","96c00ce3.9f343"]]},{"id":"66f435ae.25292c","type":"change","z":"48a2710e.b4384","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"myrawdate","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":980,"wires":[["dd5ac8c7.8182b8"]]},{"id":"2d78ca24.7df136","type":"delay","z":"48a2710e.b4384","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":740,"y":1060,"wires":[["a9329680.1a7bb8","aa57b088.3d998"]]},{"id":"96c00ce3.9f343","type":"debug","z":"48a2710e.b4384","name":"OBJECT","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","x":1220,"y":1020,"wires":[]},{"id":"6632bce6.655014","type":"function","z":"48a2710e.b4384","name":"","func":"msg.payload = msg.payload + msg.myrawdate;\nreturn msg;","outputs":1,"noerr":0,"x":980,"y":1120,"wires":[["dd5ac8c7.8182b8","96c00ce3.9f343"]]},{"id":"aa57b088.3d998","type":"delay","z":"48a2710e.b4384","name":"","pauseType":"delay","timeout":"1","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":820,"y":1120,"wires":[["6632bce6.655014"]]}]

```

---

<div class="post-metadata">

**Author:** ![Paul-Reed](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/paul-reed/32/66906_2.png) [@Paul-Reed](https://discourse.nodered.org/u/Paul-Reed)\
**Post date:** [13 December 2018 18:21 UTC](https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752/6 "2018-12-13T18:21:40Z")

</div>

You could always use a template node...

 ![template](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/4/4b296c0de580de12be2496670a93087986cfc09c.png)

```auto
[
    {
        "id": "5d349ec6.b27f7",
        "type": "inject",
        "z": "c53060.842a0fa",
        "name": "",
        "topic": "",
        "payload": "something ",
        "payloadType": "str",
        "repeat": "",
        "crontab": "",
        "once": false,
        "onceDelay": 0.1,
        "x": 110,
        "y": 1140,
        "wires": [
            [
                "8b3b9ad2.587968"
            ]
        ]
    },
    {
        "id": "9bf59e5e.5fe3b",
        "type": "debug",
        "z": "c53060.842a0fa",
        "name": "",
        "active": true,
        "tosidebar": true,
        "console": false,
        "tostatus": false,
        "complete": "false",
        "x": 730,
        "y": 1140,
        "wires": []
    },
    {
        "id": "8b3b9ad2.587968",
        "type": "simpletime",
        "z": "c53060.842a0fa",
        "name": "",
        "x": 280,
        "y": 1140,
        "wires": [
            [
                "ec9557dd.389a98",
                "fc5ceeec.aed8f"
            ]
        ]
    },
    {
        "id": "fc5ceeec.aed8f",
        "type": "change",
        "z": "c53060.842a0fa",
        "name": "",
        "rules": [
            {
                "t": "set",
                "p": "payload",
                "pt": "msg",
                "to": "myrawdate",
                "tot": "msg"
            }
        ],
        "action": "",
        "property": "",
        "from": "",
        "to": "",
        "reg": false,
        "x": 510,
        "y": 1140,
        "wires": [
            [
                "9bf59e5e.5fe3b"
            ]
        ]
    },
    {
        "id": "ec9557dd.389a98",
        "type": "delay",
        "z": "c53060.842a0fa",
        "name": "",
        "pauseType": "delay",
        "timeout": "1",
        "timeoutUnits": "seconds",
        "rate": "1",
        "nbRateUnits": "1",
        "rateUnits": "second",
        "randomFirst": "1",
        "randomLast": "5",
        "randomUnits": "seconds",
        "drop": false,
        "x": 290,
        "y": 1220,
        "wires": [
            [
                "13349c6b.cdcbc4"
            ]
        ]
    },
    {
        "id": "13349c6b.cdcbc4",
        "type": "template",
        "z": "c53060.842a0fa",
        "name": "",
        "field": "payload",
        "fieldType": "msg",
        "format": "handlebars",
        "syntax": "mustache",
        "template": "{{payload}}: {{myrawdate}}",
        "output": "str",
        "x": 500,
        "y": 1220,
        "wires": [
            [
                "9bf59e5e.5fe3b"
            ]
        ]
    }
]

```

---

<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:** [13 December 2018 18:59 UTC](https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752/7 "2018-12-13T18:59:17Z")

</div>

And you say JSONata is black arts! 🙂

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [13 December 2018 20:15 UTC](https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752/8 "2018-12-13T20:15:56Z")

</div>

It’s not black arts. It’s just the way strings are visualised in the sidebar . This is similar to the way the browser tools console shows strings. They have a “ before and after. They aren’t really there in the string. Check the length of a known string.

---

<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:** [13 December 2018 21:28 UTC](https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752/9 "2018-12-13T21:28:10Z")

</div>

> [@dceejay](#):
>
> They have a “ before and after.

We all ignore the "at start of a string and the one at the end" - but this is sticking them in the middle of the debug displayed payload and including the internal ones in the length of the string

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

---

<div class="post-metadata">

**Author:** ![knolleary](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/knolleary/32/3_2.png) [@knolleary](https://discourse.nodered.org/u/knolleary)\
**Post date:** [13 December 2018 22:00 UTC](https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752/10 "2018-12-13T22:00:24Z")

</div>

You have so many different things wired to the Debug nodes, its hard to look at that Debug output and know what path it has taken through your flow.

In the screenshots you attached to this reply - [Issue with node-red-contrib-simpletime](https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752/5) - there are no extra quotes in the middle of the string. So what is different between the flow that generate those debug messages and whatever flow generated the debug messages in your most recent reply that include the extra quotes.

---

<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:** [13 December 2018 22:10 UTC](https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752/11 "2018-12-13T22:10:54Z")

</div>

simplest flow that shows the issue

```auto
[{"id":"e8871fe0.aab65","type":"inject","z":"48a2710e.b4384","name":"","topic":"","payload":"something ","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":1440,"wires":[["2671dc0f.ed7a54"]]},{"id":"898ef286.5edec","type":"debug","z":"48a2710e.b4384","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":950,"y":1440,"wires":[]},{"id":"2671dc0f.ed7a54","type":"simpletime","z":"48a2710e.b4384","name":"","x":450,"y":1440,"wires":[["286d9d0f.fd5b42"]]},{"id":"286d9d0f.fd5b42","type":"change","z":"48a2710e.b4384","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload & myrawdate","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":1440,"wires":[["898ef286.5edec"]]}]

```

produces this in debug  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/2X/0/06f88c545c2823bbd2d03bd3d8d634fe696e5338.png)

But its not confined to the simpletime node

This flow give identical results

```auto
[{"id":"803bbfb.1c8c54","type":"inject","z":"48a2710e.b4384","name":"","topic":"","payload":"something ","payloadType":"str","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":260,"y":1520,"wires":[["85d3359a.6f1528"]]},{"id":"d391325.fb8acd","type":"debug","z":"48a2710e.b4384","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","x":950,"y":1520,"wires":[]},{"id":"858c9488.9aa0e8","type":"change","z":"48a2710e.b4384","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload & myrawdate","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":680,"y":1520,"wires":[["d391325.fb8acd"]]},{"id":"85d3359a.6f1528","type":"function","z":"48a2710e.b4384","name":"","func":"msg.myrawdate = new Date();\nreturn msg;","outputs":1,"noerr":0,"x":450,"y":1520,"wires":[["858c9488.9aa0e8"]]}]

```

It seems that JSONata is just not handling the concatenation of a string with a date object as well as it could

---

<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:** [13 December 2018 22:20 UTC](https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752/12 "2018-12-13T22:20:17Z")

</div>

Digging thru javascript/JSONata documentation (and further testing)I think the issue is that JSONata is using JSON.Stringify to convert nearly all objects to strings.

_i.e its not the concatenation that is the issue - its the basic conversion from data object to a string that is an issue_

And this doesn't work cleanly if the object is a date (needs to use .toString() instead)

If people agree with my reasoning, I'll go looking for a JSONata forum and raise it on there

---

<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:** [14 December 2018 08:44 UTC](https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752/13 "2018-12-14T08:44:33Z")

</div>

I went to [jsonata.org](http://jsonata.org) but the website is down (at least for me)

I wonder if anyone could contact the JSONata people/person and find out the situation with it?  
[edit]its backup now 🙂 [/edit]

---

<div class="post-metadata">

**Author:** ![droberts](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/droberts/32/40295_2.png) [@droberts](https://discourse.nodered.org/u/droberts)\
**Post date:** [25 November 2019 16:10 UTC](https://discourse.nodered.org/t/issue-with-node-red-contrib-simpletime/5752/14 "2019-11-25T16:10:58Z")

</div>

Edit: Totally missed how old this post was!

This is probably not the cleanest way to do it, but we have been using a custom function to generate a time string. We were having time zone issues and daylight savings issues with our SQL database and a local log, so decided to just build the string ourselves which made sure no implicit timezone stuff happened in the background. You could probably use it to build a string in the format you want:

```auto
function pad(n) {
    return n<10 ? '0'+n : n;
}
var currentDate = new Date();
var date = currentDate.getDate();
var month = currentDate.getMonth(); 
var year = currentDate.getFullYear();
var YYYYMMDD = year + "-" + pad(month+1) + "-" + pad(date);
var HH = currentDate.getHours();
var MM = currentDate.getMinutes();
var SS = currentDate.getSeconds();
var HHMMSS = pad(HH) +":"+ pad(MM) +":"+pad(SS);
var now = YYYYMMDD+'T'+HHMMSS+'.000Z';
global.set("EndTime", now);
return msg

```
