# Get time matching ui\_date\_picker

**URL:** <https://discourse.nodered.org/t/get-time-matching-ui-date-picker/42601>\
**Category:** General\
**Created:** [14 March 2021 00:48 UTC](https://discourse.nodered.org/t/get-time-matching-ui-date-picker/42601 "2021-03-14T00:48:07Z")\
**Posts on this page:** 1\
**Showing post:** 9

<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:** [14 March 2021 20:25 UTC](https://discourse.nodered.org/t/get-time-matching-ui-date-picker/42601/9 "2021-03-14T20:25:35Z")

</div>

Try this...

> [@Dashboard ui\_Form Date](https://discourse.nodered.org/t/dashboard-ui-form-date/32511/18):
>
> Demo... Chosen date was 2020/09/06... [image] ... times are output in UTC, I am in UTC+1 (so add the offset and you get 00:00 of the correct date) The issue is purely visual - the date / time is in-fact correct, merely represented as UTC. If need be, you can use a function like below to get a local date/time representation... function convertUTCDateToLocalDate(date) { var newDate = new Date(date.getTime()+date.getTimezoneOffset()\*60\*1000); var offset = date.getTimezoneOffset() / 6…

Essentially, this function can deduct the time offset based on timezone to ensure correct date...

```javascript
msg.payload = convertUTCDateToLocalDate(msg.payload);

return msg;

function convertUTCDateToLocalDate(date) {
    date = new Date(date);
    var newDate = new Date(date.getTime() + date.getTimezoneOffset() * 60 * 1000);
    var offset = date.getTimezoneOffset() / 60;
    var hours = date.getHours();
    newDate.setHours(hours - offset);
    return newDate;
}

```

---

_[View the full topic](https://discourse.nodered.org/t/get-time-matching-ui-date-picker/42601)._
