# Difference in Time Zone in UI Builder

**URL:** https://discourse.nodered.org/t/difference-in-time-zone-in-ui-builder/65303
**Category:** General
**Tags:** uibuilder
**Created:** [19 July 2022 08:25 UTC](https://discourse.nodered.org/t/difference-in-time-zone-in-ui-builder/65303 "2022-07-19T08:25:00Z")
**Posts on this page:** 9
**Page:** 1

<div class="post-metadata">

### Author: ![TROJAN053](https://avatars.discourse-cdn.com/v4/letter/t/7cd45c/32.png) [@TROJAN053](https://discourse.nodered.org/u/TROJAN053)
#### Post date: [19 July 2022 08:25 UTC](https://discourse.nodered.org/t/difference-in-time-zone-in-ui-builder/65303/1 "2022-07-19T08:25:01Z")

</div>

HI,  
I am using a UI Builder to show data from my SQL Server. The data is having difference in TIME ZONE i guess in UI Builder to that of SQL Server. My Payload data is also coming same time zone as of SQL Server but in UI it shows different.  
Kindly Help.

 ![DB](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/1/e/1e9993a3be11d1d9f79ebac1416d6f2ef4c800bc.jpeg)  
 ![portal](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/c/b/cbf3f09c15fd1334fc5adc6b65fcf72417616af8.jpeg)

---

<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: [19 July 2022 10:15 UTC](https://discourse.nodered.org/t/difference-in-time-zone-in-ui-builder/65303/2 "2022-07-19T10:15:38Z")

</div>

Clearly you are in a timezone that is 5 1/2 hrs later than UTC. The web interface is showing UTC but it looks like you are storing local time in the db.

It is best practice to store UTC in a db since anything else leaves you open to the whims of DST and TZ changes.

Then show local times for user input/output for convenience.

This, of course, would be the same whether using uibuilder or not. I suspect that the node you are using to get data from the DB is converting SQL Server timestamps into JavaScript Dates, when you send a Javascript object as a msg to uibuilder (or Dashboard for that matter), because it has to go via websockets (more accurately [Socket.IO](http://Socket.IO)) which does not support JavaScript objects directly, it has to be "serialised" (e.g. turned into text) and then turned back at the other end. Normally, you don't notice this happening. However, JavaScript Date objects are serialised to an ISO time string and can't be automatically changed back. That is what you are seeing in your UI.

So to show the data in a local format, you need to convert the timestamp columns in the table back to a local, human readable format. Check out the `Intl` tools for that.

[Intl - JavaScript | MDN (mozilla.org)](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl)

---

<div class="post-metadata">

### Author: ![TROJAN053](https://avatars.discourse-cdn.com/v4/letter/t/7cd45c/32.png) [@TROJAN053](https://discourse.nodered.org/u/TROJAN053)
#### Post date: [20 July 2022 01:23 UTC](https://discourse.nodered.org/t/difference-in-time-zone-in-ui-builder/65303/3 "2022-07-20T01:23:26Z")

</div>

![Time](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/5/8592353fa28b8e759c462e72c0aeb5749b8b1cbe.jpeg)  
Hi,  
Thanks a lot for the info. I would appreciate if you could help me out on where and how to convert the time stamp. I have tried the Intl Solutions mentioned but didn't get success. Here i am making and array of data in which Starttime & CloseTime is my key for UI builder JS file which is sending using HTTP request (Mainly [Socket.IO](http://Socket.IO)).

---

<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: [20 July 2022 14:38 UTC](https://discourse.nodered.org/t/difference-in-time-zone-in-ui-builder/65303/4 "2022-07-20T14:38:58Z")

</div>

sorry, cant do examples at the moment as i have a broken thumb in a cast. you should be able to find examples on the web.

replace you e. vars with calculated values using the intl library.

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [20 July 2022 16:23 UTC](https://discourse.nodered.org/t/difference-in-time-zone-in-ui-builder/65303/5 "2022-07-20T16:23:20Z")

</div>

@TROJAN053 I would make a test. What happens if you replace:

`Starttime : e.Start_Time`

with:

`Starttime: new Date(e.Start_Time)`

?

---

<div class="post-metadata">

### Author: ![TROJAN053](https://avatars.discourse-cdn.com/v4/letter/t/7cd45c/32.png) [@TROJAN053](https://discourse.nodered.org/u/TROJAN053)
#### Post date: [21 July 2022 00:46 UTC](https://discourse.nodered.org/t/difference-in-time-zone-in-ui-builder/65303/6 "2022-07-21T00:46:56Z")

</div>

No change, Payload is still the same.

---

<div class="post-metadata">

### Author: ![fmarzocca](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/fmarzocca/32/35901_2.png) [@fmarzocca](https://discourse.nodered.org/u/fmarzocca)
#### Post date: [21 July 2022 07:22 UTC](https://discourse.nodered.org/t/difference-in-time-zone-in-ui-builder/65303/7 "2022-07-21T07:22:05Z")

</div>

The results depend on the locale of your browser. You can try with the **`toLocaleDateString()`** method, which returns a string with a language-sensitive representation of the date portion of the specified date in the user agent's timezone.

---

<div class="post-metadata">

### Author: ![TROJAN053](https://avatars.discourse-cdn.com/v4/letter/t/7cd45c/32.png) [@TROJAN053](https://discourse.nodered.org/u/TROJAN053)
#### Post date: [23 July 2022 00:21 UTC](https://discourse.nodered.org/t/difference-in-time-zone-in-ui-builder/65303/8 "2022-07-23T00:21:23Z")

</div>

HI,  
Finally my problem resolves using MSSQL Node Plus, this actually supports UTC time format and finally there no change in time to IST in payload.

---

<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: [21 September 2022 00:22 UTC](https://discourse.nodered.org/t/difference-in-time-zone-in-ui-builder/65303/9 "2022-09-21T00:22:12Z")

</div>

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