# UI-Table timestamp with correct TZ

**URL:** https://discourse.nodered.org/t/ui-table-timestamp-with-correct-tz/39958
**Category:** Dashboard
**Created:** [28 January 2021 21:45 UTC](https://discourse.nodered.org/t/ui-table-timestamp-with-correct-tz/39958 "2021-01-28T21:45:09Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![comins58](https://avatars.discourse-cdn.com/v4/letter/c/8dc957/32.png) [@comins58](https://discourse.nodered.org/u/comins58)
#### Post date: [28 January 2021 21:45 UTC](https://discourse.nodered.org/t/ui-table-timestamp-with-correct-tz/39958/1 "2021-01-28T21:45:10Z")

</div>

Howdy,  
Loving Node-Red and that I have a dashboard table pulling from a DB using only 2 lines of code.

I grab sensor data from various ESP32 nodes via MQTT and stick them in a MariaDB.

I have Node Red running on a Rasberry PI V1.2.6  
Time is stored as a standard Linux TimeStamp format in the DB.

Simple table and phpmyadmin displays it as:

TimeStamp Source Topic DataValue

2021-01-28 15:00:29 frontdoor temperature 31

- many rows.  
Note that phpmyadmin converts the TimeStamp to my TimeZone for an easy to read format.

Then in node-red function node I have:  
msg.topic = 'Select \* FROM sensors ORDER BY TIMESTAMP DESC LIMIT 12;';  
return msg;

I connect this function node to a mysql node then to the UI\_Table and all works great and  
was very simple/clean. Display is just like the table above except the TimeStamp is displayed in UTC which is hard to read. ie. 2021-01-28T20:53:30.00Z

Is there an easy way in this stream to convert the Timestamp to display using my TimeZone NY.  
This is what is fed to the table:

array[12]  
[0 … 9]  
0: object  
TimeStamp: "2021-01-28T21:32:31.000Z"  
Source: "frontdoor"  
Topic: "temperature"  
DataValue: 28  
1: object  
TimeStamp: "2021-01-28T21:31:31.000Z"  
Source: "frontdoor"  
Topic: "temperature"  
DataValue: 28

Thanks,  
-steve

---

<div class="post-metadata">

### Author: ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)
#### Post date: [28 January 2021 21:54 UTC](https://discourse.nodered.org/t/ui-table-timestamp-with-correct-tz/39958/2 "2021-01-28T21:54:28Z")

</div>

> [@comins58](#):
>
> Display is just like the table above except the TimeStamp is displayed in UTC which is hard to read. ie. 2021-01-28T20:53:30.00Z

Well hard-to-read is relative. Actually it is very easy to read once you get used to it. And no problems with month-first vs date-first. You can convert in a function node with `const ts = new Date(TimeStamp)`.

---

<div class="post-metadata">

### Author: ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)
#### Post date: [28 January 2021 22:45 UTC](https://discourse.nodered.org/t/ui-table-timestamp-with-correct-tz/39958/3 "2021-01-28T22:45:00Z")

</div>

> [@comins58](#):
>
> Select \* FROM sensors ORDER BY TIMESTAMP DESC LIMIT 12;

Maybe you can try making the tz convertion directly from sql with

```javascript
SELECT CONVERT_TZ(TimeStamp,'+00:00','+04:00') AS TIMESTAMP, Source, Topic, DataValue FROM sensors ORDER BY TIMESTAMP DESC LIMIT 12 ;

```

[Date & Time Function - CONVERT\_TZ](https://mariadb.com/kb/en/convert_tz/)

adjust +04:00 according to your tz offset

---

<div class="post-metadata">

### Author: ![comins58](https://avatars.discourse-cdn.com/v4/letter/c/8dc957/32.png) [@comins58](https://discourse.nodered.org/u/comins58)
#### Post date: [29 January 2021 15:48 UTC](https://discourse.nodered.org/t/ui-table-timestamp-with-correct-tz/39958/4 "2021-01-29T15:48:20Z")

</div>

Nice - thanks

---

<div class="post-metadata">

### Author: ![comins58](https://avatars.discourse-cdn.com/v4/letter/c/8dc957/32.png) [@comins58](https://discourse.nodered.org/u/comins58)
#### Post date: [29 January 2021 15:49 UTC](https://discourse.nodered.org/t/ui-table-timestamp-with-correct-tz/39958/5 "2021-01-29T15:49:18Z")

</div>

thanks - appreciated

---

<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: [28 February 2021 15:49 UTC](https://discourse.nodered.org/t/ui-table-timestamp-with-correct-tz/39958/6 "2021-02-28T15:49:45Z")

</div>

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