`dayjs("2013-11-18T11:55:20").tz("America/Toronto")` does not work
- Dominant language
- JavaScript
- Stars
- 48.7k
- Forks
- 2.5k
- PR merge metrics
- No merged PRs in 30d
Description
**Describe the bug**
`dayjs("2013-11-18T11:55:20").tz("America/Toronto")` (as suggested in the [docs](https://day.js.org/docs/en/timezone/timezone)) outputs the following:
```js
const dayjs = require('dayjs')
const utc = require('dayjs/plugin/utc')
const timezone = require('dayjs/plugin/timezone')
dayjs.extend(utc)
dayjs.extend(timezone)
console.log(dayjs('2013-11-18T11:55:20').tz('America/Toronto'))
// Output
{
'$L': 'en',
'$d': Invalid Date,
'$x': { '$timezone': 'America/Toronto' },
'$y': NaN,
'$M': NaN,
'$D': NaN,
'$W': NaN,
'$H': NaN,
'$m': NaN,
'$s': NaN,
'$ms': NaN,
'$offset': NaN,
'$u': false
}
```
**Expected behavior**
The following should be the output:
```js
{
'$L': 'en',
'$d': 2013-11-18T10:55:20.000Z,
'$x': { '$localOffset': -60, '$timezone': 'America/Toronto' },
'$y': 2013,
'$M': 10,
'$D': 18,
'$W': 1,
'$H': 11,
'$m': 55,
'$s': 20,
'$ms': 0,
'$offset': -300
}
```
**Information**
- Day.js Version: `1.11.6`, `1.11.0`, `1.10.0`, `1.9.0` (it seems like the bug is in all versions since `utc` plugin was introduced)
- OS: [e.g. iOS]: Arch Linux
- Browser [e.g. chrome 62]: n/a
- Time zone: [e.g. GMT-07:00 DST (Pacific Daylight Time)]: tested with `America/Toronto` and `Europe/Slovakia`; I don’t think it matters;
- Node version: `19.0.0`
- NPM version: `8.19.2`
Contributor guide
Assessment
This issue has not been assessed yet.