iamkun / iamkun/dayjs

DayJS Timezone Does Not Accept UTC (Zulu) Timestamp as Argument

Open
#1,273 2 comments 3 reactions 0 assignees View on GitHub
Dominant language
JavaScript
Stars
48.7k
Forks
2.5k
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
Hey! Just first things first I want to say thanks for the library. Our team is in the process of getting rid of momentJS across the whole app and we are attempting to convert fully over to dayJS but ran into this issue today.

In Moment-Timezone you can pass a timestamp as follows using the Zulu format and an olson timezone to convert a date.

```
moment.tz("2020-12-14 19:58:00.000Z", 'America/New_York').format()
// returns 2020-12-14T14:58:00-05:00
```

DayJS appears to be ignoring the "Z" formatting:

```
dayjs.tz('2020-12-14 19:58:00.000Z', 'America/New_York').format()
// returns 2020-12-14T19:58:00-05:00
```

**Expected behavior**
I would expect the output of dayJS and MomentJS this to be the same given the same input. There might be a DayJS Method we could use to get the same result but I am currently unaware of it.

**Information**
- Day.js Version: 1.9.7
- OS: Mac OS Mojave 10.14.6
- Browser [e.g. chrome 62]
- Time zone: US Eastern Standard Time (EST -5:00)

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the reported dayjs.tz(...) call with the Zulu timestamp and America/New_York timezone, then trace the timezone parsing and formatting entry points. Done means the call preserves the UTC offset and returns the expected 2020-12-14T14:58:00-05:00 result, matching the Moment-Timezone example.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.