DayJS giving wrong output on GMT
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
I am trying to convert different times from different zones into GMT. This will allow me to send them notifications according to their time zone. I noticed it worked perfectly for other time zones, but when I passed GMT or UTC, it gave the wrong time.
```js
const dayjs = require("dayjs");
const utc = require("dayjs/plugin/utc");
const timezone = require("dayjs/plugin/timezone");
dayjs.extend(utc);
dayjs.extend(timezone);
let zone = "UTC";
let hrs = 10;
let mins = 0;
const zoneTimeInGMT =
dayjs()
.tz(zone)
.hour(hrs)
.minute(mins)
.utc()
.format("dddd MMMM DD YYYY HH:mm:ss") + " GMT";
console.log({ zoneTimeInGMT });
```

For other timezones
```js
let zone = "America/New_York";
let hrs = 10;
let mins = 0;
const zoneTimeInGMT =
dayjs()
.tz(zone)
.hour(hrs)
.minute(mins)
.utc()
.format("dddd MMMM DD YYYY HH:mm:ss") + " GMT";
console.log({ zoneTimeInGMT });
```

Contributor guide
Research direction
Reproduce the UTC and America/New_York snippets using the utc and timezone plugin entry points. Compare the formatted UTC result with the requested 10:00 time, then trace how the timezone conversion handles the UTC zone. Done means the UTC case produces the correct GMT time without regressing other zones.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100