Skip to content

dayjs("2013-11-18T11:55:20").tz("America/Toronto") does not work #2102

Open
@tukusejssirs

Description

@tukusejssirs

Describe the bug
dayjs("2013-11-18T11:55:20").tz("America/Toronto") (as suggested in the docs) outputs the following:

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:

{
  '$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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions