# Get time and date on raspberry

**URL:** <https://discourse.nodered.org/t/get-time-and-date-on-raspberry/43824>\
**Category:** Dashboard\
**Created:** [7 April 2021 16:26 UTC](https://discourse.nodered.org/t/get-time-and-date-on-raspberry/43824 "2021-04-07T16:26:52Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![achrefnajjar](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@achrefnajjar](https://discourse.nodered.org/u/achrefnajjar)\
**Post date:** [7 April 2021 16:26 UTC](https://discourse.nodered.org/t/get-time-and-date-on-raspberry/43824/1 "2021-04-07T16:26:52Z")

</div>

hello my friends can i'm wondering how to get time and date to a text node using a function node when working on raspberry pi ? thanks.

---

<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:** [7 April 2021 16:35 UTC](https://discourse.nodered.org/t/get-time-and-date-on-raspberry/43824/2 "2021-04-07T16:35:49Z")

</div>

You could use Angular and format the timestamp in the text node value input  
`{{msg.payload| date : "dd-MM-yyyy HH:mm:ss" }}`

> **[Angular Date Pipe & formatting dates in Angular with examples | Angular Wiki](https://www.angularjswiki.com/angular/angular-date-pipe-formatting-date-times-in-angular-with-examples/)**
>
> Angular date pipe used to format dates in angular according to the given date formats,timezone and country locale information.

```auto
[{"id":"691636cb.ea6028","type":"inject","z":"5a245aa1.510164","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"","payloadType":"date","x":270,"y":3780,"wires":[["1a4503eb.b9f6c4"]]},{"id":"1a4503eb.b9f6c4","type":"ui_text","z":"5a245aa1.510164","group":"8b5cde76.edd58","order":4,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload| date : \"dd-MM-yyyy HH:mm:ss\" }}","layout":"row-spread","x":420,"y":3780,"wires":[]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"8f03e639.85956","order":1,"disp":true,"width":"6","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

---

<div class="post-metadata">

**Author:** ![achrefnajjar](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@achrefnajjar](https://discourse.nodered.org/u/achrefnajjar)\
**Post date:** [7 April 2021 16:47 UTC](https://discourse.nodered.org/t/get-time-and-date-on-raspberry/43824/3 "2021-04-07T16:47:52Z")

</div>

it doesn't work my friend i tried it in both windows and raspberry pi  
there is one detail that i forgot to mention it that i've been working on windows and i ve used this script in a function `var now = new Date().toLocaleString("en-EN"); return {payload: now}; and it worked well` but it doesn't on raspberry pi

---

<div class="post-metadata">

**Author:** ![achrefnajjar](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@achrefnajjar](https://discourse.nodered.org/u/achrefnajjar)\
**Post date:** [7 April 2021 16:56 UTC](https://discourse.nodered.org/t/get-time-and-date-on-raspberry/43824/4 "2021-04-07T16:56:34Z")

</div>

i'm sorry it was so rediculous from me not to click on timestamp button it worked fine .  
thank u very much

---

<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:** [7 April 2021 16:57 UTC](https://discourse.nodered.org/t/get-time-and-date-on-raspberry/43824/5 "2021-04-07T16:57:31Z")

</div>

> [@achrefnajjar](#):
>
> i ve used this script in a function `var now = new Date().toLocaleString("en-EN"); return {payload: now}; and it worked well` but it doesn't on raspberry pi

That's likely due to node version difference.

What version does windows have (my money is on v14) and what version node on pi? (I guess V12 or below)

---

<div class="post-metadata">

**Author:** ![achrefnajjar](https://avatars.discourse-cdn.com/v4/letter/a/8e8cbc/32.png) [@achrefnajjar](https://discourse.nodered.org/u/achrefnajjar)\
**Post date:** [7 April 2021 17:22 UTC](https://discourse.nodered.org/t/get-time-and-date-on-raspberry/43824/6 "2021-04-07T17:22:49Z")

</div>

no my friend that method does work too but like i said it was silly of m not pressing the timestamp's button

---

<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:** [7 May 2021 17:23 UTC](https://discourse.nodered.org/t/get-time-and-date-on-raspberry/43824/7 "2021-05-07T17:23:09Z")

</div>

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