# JSON Expression Blink save.video timestamp

**URL:** <https://discourse.nodered.org/t/json-expression-blink-save-video-timestamp/71397>\
**Category:** General\
**Created:** [28 November 2022 18:12 UTC](https://discourse.nodered.org/t/json-expression-blink-save-video-timestamp/71397 "2022-11-28T18:12:37Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bughatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bughatti/32/71516_2.png) [@bughatti](https://discourse.nodered.org/u/bughatti)\
**Post date:** [28 November 2022 18:12 UTC](https://discourse.nodered.org/t/json-expression-blink-save-video-timestamp/71397/1 "2022-11-28T18:12:37Z")

</div>

I am trying to move over some of my automations from home assistant to node red. in HA, I had an automation that wrote a filename to storage when motion was detected on my blink cameras.

/media/blink/backalley\_blink\_video\_{{ now().strftime('%Y%m%d\_%H%M%S') }}.mp4

and this filename worked fine. All saved videos had a timestamp in them. When I moved over the code in node red for a json expression, it saves fine but does not timestamp it.

`{ "name":"back_alley_street", "filename":"/media/blink/backalley_blink_video_{{ now().strftime('%Y%m%d_%H%M%S') }}.mp4" }`

It just shows as backalley\_blink\_video\_{{ now().strftime('%Y%m%d\_%H%M%S') }}.mp4 in my storage.

What is the proper way to get each new file to save with the write timestamp, also I am mountain time.

---

<div class="post-metadata">

**Author:** ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)\
**Post date:** [28 November 2022 20:08 UTC](https://discourse.nodered.org/t/json-expression-blink-save-video-timestamp/71397/2 "2022-11-28T20:08:05Z")

</div>

You would need to use a JSONata expression in a change node.  
e.g.

```auto
[{"id":"4b89a6392a059f18","type":"inject","z":"452103ea51141731","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":180,"y":3640,"wires":[["4dfbe838e3a6b816"]]},{"id":"4dfbe838e3a6b816","type":"change","z":"452103ea51141731","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"{\t \"name\": \"back_alley_street\",\t \"filename\": \"/media/blink/backalley_blink_video_\" &\t $moment().tz(\"America/Edmonton\").format(\"YYYYMMDDHHmmss\") & \t \".mp4\" \t}","tot":"jsonata"}],"action":"","property":"","from":"","to":"","reg":false,"x":360,"y":3640,"wires":[["f6e8ac13a798492d"]]},{"id":"f6e8ac13a798492d","type":"debug","z":"452103ea51141731","name":"debug 109","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":590,"y":3600,"wires":[]}]

```

Expression

```auto
{
   "name": "back_alley_street",
   "filename": "/media/blink/backalley_blink_video_" &
     $moment().tz("America/Edmonton").format("YYYYMMDDHHmmss") & 
     ".mp4" 
}

```

[https://momentjs.com/docs/#/displaying/format/](https://momentjs.com/docs/#/displaying/format/)

> **[Other Operators · JSONata](https://docs.jsonata.org/other-operators)**
>
> \## \`&\` (Concatenation)

---

<div class="post-metadata">

**Author:** ![bughatti](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/bughatti/32/71516_2.png) [@bughatti](https://discourse.nodered.org/u/bughatti)\
**Post date:** [28 November 2022 20:12 UTC](https://discourse.nodered.org/t/json-expression-blink-save-video-timestamp/71397/3 "2022-11-28T20:12:23Z")

</div>

That worked, thank you!!

---

<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:** [12 December 2022 20:13 UTC](https://discourse.nodered.org/t/json-expression-blink-save-video-timestamp/71397/4 "2022-12-12T20:13:13Z")

</div>

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