# Set a timestamp when something happens

**URL:** <https://discourse.nodered.org/t/set-a-timestamp-when-something-happens/82276>\
**Category:** General\
**Created:** [23 October 2023 08:44 UTC](https://discourse.nodered.org/t/set-a-timestamp-when-something-happens/82276 "2023-10-23T08:44:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![crashoverhead](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/crashoverhead/32/44849_2.png) [@crashoverhead](https://discourse.nodered.org/u/crashoverhead)\
**Post date:** [23 October 2023 08:44 UTC](https://discourse.nodered.org/t/set-a-timestamp-when-something-happens/82276/1 "2023-10-23T08:44:33Z")

</div>

Hello everyone,  
I'm going crazy trying to find a simple solution to set a timestamp in my flow.  
In practice I have a flow with inject every second and at the rising edge , from OFF to ON of a boolean, I would like to set a timestamp.

I can't find the solution, can anyone help me?

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [23 October 2023 08:52 UTC](https://discourse.nodered.org/t/set-a-timestamp-when-something-happens/82276/2 "2023-10-23T08:52:19Z")

</div>

Do you mean that you get a series of messages like this?

```auto
false
false
false
true
true

```

What does "set a timestamp" mean -  
Add msg.timestamp to the first msg where payload == true?  
Set/change a global/flow/context variable?

---

<div class="post-metadata">

**Author:** ![crashoverhead](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/crashoverhead/32/44849_2.png) [@crashoverhead](https://discourse.nodered.org/u/crashoverhead)\
**Post date:** [23 October 2023 08:55 UTC](https://discourse.nodered.org/t/set-a-timestamp-when-something-happens/82276/3 "2023-10-23T08:55:07Z")

</div>

Yes a receive  
false  
false  
false  
true  
true

and at the first True i qould like to set a msg.payload.timestamp or flow.timestamp;

---

<div class="post-metadata">

**Author:** ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)\
**Post date:** [23 October 2023 09:03 UTC](https://discourse.nodered.org/t/set-a-timestamp-when-something-happens/82276/4 "2023-10-23T09:03:30Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/1/71f8225d3fa151889bc5fe15697d9ff8547f3ce6.png)

```auto
[{"id":"60aed1d242dbbb1b","type":"inject","z":"9df5622ef37b49d6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"true","payloadType":"bool","x":110,"y":280,"wires":[["db3ac64fdd9c5da5"]]},{"id":"db3ac64fdd9c5da5","type":"rbe","z":"9df5622ef37b49d6","name":"block unless value changes","func":"rbe","gap":"","start":"","inout":"out","septopics":true,"property":"payload","topi":"topic","x":320,"y":300,"wires":[["2be7f55866c0ddab"]]},{"id":"23e3f7f4c3b49d54","type":"inject","z":"9df5622ef37b49d6","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"false","payloadType":"bool","x":110,"y":320,"wires":[["db3ac64fdd9c5da5"]]},{"id":"2be7f55866c0ddab","type":"switch","z":"9df5622ef37b49d6","name":"true?","property":"payload","propertyType":"msg","rules":[{"t":"true"}],"checkall":"true","repair":false,"outputs":1,"x":530,"y":300,"wires":[["302c89b39a40f5c0"]]},{"id":"302c89b39a40f5c0","type":"debug","z":"9df5622ef37b49d6","name":"debug 417","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":690,"y":300,"wires":[]}]

```

---

<div class="post-metadata">

**Author:** ![crashoverhead](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/crashoverhead/32/44849_2.png) [@crashoverhead](https://discourse.nodered.org/u/crashoverhead)\
**Post date:** [23 October 2023 12:26 UTC](https://discourse.nodered.org/t/set-a-timestamp-when-something-happens/82276/5 "2023-10-23T12:26:00Z")

</div>

it work ! thanks !

---

<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:** [6 November 2023 12:26 UTC](https://discourse.nodered.org/t/set-a-timestamp-when-something-happens/82276/6 "2023-11-06T12:26:10Z")

</div>

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