# Dates: now() is wrong when formatted

**URL:** <https://community.weweb.io/t/dates-now-is-wrong-when-formatted/1804>\
**Category:** Ask us anything\
**Created:** [February 3, 2023, 2:30pm UTC](https://community.weweb.io/t/dates-now-is-wrong-when-formatted/1804 "2023-02-03T14:30:08Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![aeynaud](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/aeynaud/32/2050_2.png) [@aeynaud](https://community.weweb.io/u/aeynaud)\
**Post date:** [February 3, 2023, 2:30pm UTC](https://community.weweb.io/t/dates-now-is-wrong-when-formatted/1804/1 "2023-02-03T14:30:08Z")

</div>

Hey there!

I noticed something strange with dates today. I am only realizing now that I am close to midnight and the timezone being off by a few hours made me notice that the day is wrong.

![WeWeb](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/8/8f3b0b8c06b8d63ca05219b9138667c9d74f2a2d.gif)

Even without using the `formatDate()` function, when I set the init value of a date picker to the base WeWeb `now()` function, it gives me the wrong date/time.

Basically, every time the current date is transformed in any way, it uses the wrong timezone. Does anyone know how I could get around this?

Thank you in advance!

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dorilama/32/10403_2.png) [@dorilama](https://community.weweb.io/u/dorilama)\
**Post date:** [February 3, 2023, 4:00pm UTC](https://community.weweb.io/t/dates-now-is-wrong-when-formatted/1804/2 "2023-02-03T16:00:03Z")

</div>

The two stringified dates have two different timezones: the first one is in UTC but the second one is in UTC+8.  
`2023-02-03T22:00:00Z` is the same time as `2023-02-04T06:00:00+08:00` just displayed in two different timezones as you can check [here](https://www.timeanddate.com/worldclock/converter.html?iso=20230203T220000&p1=3910&p2=1440).

But something strange is happening. The following are simulated timezones using devtools displayed in text element, date element and date picker.

![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/3/34bc9f7530229c4e7d236cfb37ed2cb01acf31ef.png)

* * *

![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/0/000a3fe8d7c10a6352b420b2b60d3792b9f22717.png)

* * *

 ![image](https://us1.discourse-cdn.com/flex016/uploads/weweb/original/2X/9/93e31966e1ff5c9894daf31edd8e27b670bf2481.png)

I think the behaviour you are expecting when you ask for the current time is what you get from `new Date()` (`new Date().toISOString()` if you want a string)

---

<div class="post-metadata">

**Author:** ![aeynaud](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/aeynaud/32/2050_2.png) [@aeynaud](https://community.weweb.io/u/aeynaud)\
**Post date:** [February 4, 2023, 3:44am UTC](https://community.weweb.io/t/dates-now-is-wrong-when-formatted/1804/3 "2023-02-04T03:44:55Z")

</div>

@dorilama I’m not sure I understood your workaround in your last sentence.  
No matter what date/time I feed to a date picker input, the date picker transforms the time-zone to something else.

Even if the init time given is a string, or even numerical, it always converts it.

---

<div class="post-metadata">

**Author:** ![dorilama](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/dorilama/32/10403_2.png) [@dorilama](https://community.weweb.io/u/dorilama)\
**Post date:** [February 4, 2023, 10:27am UTC](https://community.weweb.io/t/dates-now-is-wrong-when-formatted/1804/4 "2023-02-04T10:27:22Z")

</div>

You can see in my screenshots that if you set the initial value, of both date element and date picker element, to `new Date()` the correct current date is visualized without any change.

---

<div class="post-metadata">

**Author:** ![aeynaud](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/aeynaud/32/2050_2.png) [@aeynaud](https://community.weweb.io/u/aeynaud)\
**Post date:** [February 4, 2023, 11:49am UTC](https://community.weweb.io/t/dates-now-is-wrong-when-formatted/1804/5 "2023-02-04T11:49:46Z")

</div>

Oh I see! Many thanks, all good!
