# DatePicker utc not working

**URL:** <https://forum.radzen.com/t/datepicker-utc-not-working/680>\
**Category:** Angular\
**Created:** [November 13, 2018, 7:41pm UTC](https://forum.radzen.com/t/datepicker-utc-not-working/680 "2018-11-13T19:41:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![SeaderGamer](https://forum.radzen.com/user_avatar/forum.radzen.com/seadergamer/32/455_2.png) [@SeaderGamer](https://forum.radzen.com/u/SeaderGamer)\
**Post date:** [November 13, 2018, 7:41pm UTC](https://forum.radzen.com/t/datepicker-utc-not-working/680/1 "2018-11-13T19:41:47Z")

</div>

When converting a form from an edit page to template form, the DatePicker component has an error, utc does not work correctly.

My datepicker:

 ![3](https://forum.radzen.com/uploads/default/original/1X/343da25fe4a0b38853292e4add53725203c5f57e.png)

In this print I set the utc to true (in the radzen, not in the "elements"), you can see that the radzen component is set to the right value, but the primeNG component (which is what appears) is 3 hours shorter at any of the utc values.

 ![2](https://forum.radzen.com/uploads/default/original/1X/997e0a9d44bb03305ceb3f66243a80d41c55f0b4.png)

 ![1](https://forum.radzen.com/uploads/default/original/1X/b55a4251bba5450dde3ef194c2d6659c3fdee796.png)

---

<div class="post-metadata">

**Author:** ![SeaderGamer](https://forum.radzen.com/user_avatar/forum.radzen.com/seadergamer/32/455_2.png) [@SeaderGamer](https://forum.radzen.com/u/SeaderGamer)\
**Post date:** [November 13, 2018, 8:20pm UTC](https://forum.radzen.com/t/datepicker-utc-not-working/680/2 "2018-11-13T20:20:55Z")

</div>

The datePicker of the add page is also with the same error, the upper in the image was sent with the utc set to true, and the lower one as false.  
 ![4](https://forum.radzen.com/uploads/default/original/1X/495ca88fb468d8eb5e89d0f4987140c88f199db7.png)

---

<div class="post-metadata">

**Author:** ![korchev](https://forum.radzen.com/user_avatar/forum.radzen.com/korchev/32/4_2.png) [@korchev](https://forum.radzen.com/u/korchev)\
**Post date:** [November 14, 2018, 7:41am UTC](https://forum.radzen.com/t/datepicker-utc-not-working/680/3 "2018-11-14T07:41:19Z")

</div>

JavaScript dates are by default created in the current user timezone. While this is convenient in most cases they get converted to UTC when serialized as JSON (before submitting it to a server). Since the timezone information is lost it is very hard to save the date properly at server-side unless you know what the client timezone is.

Radzen handles this by converting all dates to UTC by default. This however makes the dates appear "wrong" unless the `utcDate` pipe is used.

Here is an example that demonstrates the behavior:

 ![50](https://forum.radzen.com/uploads/default/original/1X/b60b239d0deda75999191477165774174a751f95.png)

Even though the same date is selected in both datepickers after JSON serialization the values are different. Since I am in GMT+2 there is a two hour difference.

Here is my test application: [utc-dates.zip](https://forum.radzen.com/uploads/default/original/1X/0d620b008087427e2e8cee20ccb5823fcf823f08.zip).

---

<div class="post-metadata">

**Author:** ![SeaderGamer](https://forum.radzen.com/user_avatar/forum.radzen.com/seadergamer/32/455_2.png) [@SeaderGamer](https://forum.radzen.com/u/SeaderGamer)\
**Post date:** [November 14, 2018, 5:25pm UTC](https://forum.radzen.com/t/datepicker-utc-not-working/680/4 "2018-11-14T17:25:15Z")

</div>

I know how utc works and used in the old form.  
The problem is, whether or not I enable UTC in a datepicker of the edit, it always decreases 3 hours (GMT -3) in the hours taken by the query and because the database is old the dates are saved in it as hour in the middle of the night, so always appears in datepicker as a day ago.
