# Odd date behaviour when setting hour to 17

**URL:** <https://talk.observablehq.com/t/odd-date-behaviour-when-setting-hour-to-17/2125>\
**Category:** Help\
**Created:** [July 8, 2019, 9:56pm UTC](https://talk.observablehq.com/t/odd-date-behaviour-when-setting-hour-to-17/2125 "2019-07-08T21:56:55Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mbrownshoes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbrownshoes/32/423_2.png) [@mbrownshoes](https://talk.observablehq.com/u/mbrownshoes)\
**Post date:** [July 8, 2019, 9:56pm UTC](https://talk.observablehq.com/t/odd-date-behaviour-when-setting-hour-to-17/2125/1 "2019-07-08T21:56:55Z")

</div>

For some reason in Observable (on a Mac, Chrome)

```
new Date(2019, 7, 8, 17, 0, 0, 0)

```

prints as

```
2019-08-09

```

which is obviously incorrect, while in the console it prints corrects as

```
Thu Aug 08 2019 17:00:00 GMT-0700 (Pacific Daylight Time)

```

I only find this behaviour when the hour is 17 (5pm).  
 ![37%20PM](https://canada1.discourse-cdn.com/flex030/uploads/observablehq/original/2X/6/6208a225104bdf61c447881f48bc367eeb626ed1.png)

Odd, eh?

---

<div class="post-metadata">

**Author:** ![tom](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/tom/32/2262_2.png) [@tom](https://talk.observablehq.com/u/tom)\
**Post date:** [July 8, 2019, 10:25pm UTC](https://talk.observablehq.com/t/odd-date-behaviour-when-setting-hour-to-17/2125/2 "2019-07-08T22:25:30Z")

</div>

Sure, what’s going on is in the notebook-inspector project, which is open source, and here’s the source: [https://github.com/observablehq/inspector/blob/master/src/formatDate.js](https://github.com/observablehq/inspector/blob/master/src/formatDate.js)

5pm in Pacific Daylight Time is midnight in UTC time, so we format it as a short date:

```auto
+new Date(2019, 7, 8, 17, 0, 0, 0) ===
  +new Date(Date.UTC(2019, 7, 9, 0, 0, 0, 0))

```

That said, I think we _are_ a little inconsistent in that the midnight “date” handling is UTC-centric but the default date formatting shows times in the local timezone. Perhaps we should either show formatted datetimes in UTC or indicate their timezone.

---

<div class="post-metadata">

**Author:** ![mbrownshoes](https://yyz2.discourse-cdn.com/flex030/user_avatar/talk.observablehq.com/mbrownshoes/32/423_2.png) [@mbrownshoes](https://talk.observablehq.com/u/mbrownshoes)\
**Post date:** [July 8, 2019, 10:53pm UTC](https://talk.observablehq.com/t/odd-date-behaviour-when-setting-hour-to-17/2125/3 "2019-07-08T22:53:46Z")

</div>

Ah, I see. Makes sense. Yes, either solution would be an improvement (either show the local timezone or show as UTC)

Thanks!
