Skip to content

Calling tz() overrides locale #2398

@wang-yikai

Description

@wang-yikai

Running
dayjs('2020-01-08T15:14:59.741774+00:00') .locale('es') .tz('America/New_York') .format('LLL')
gives January 8, 2020 10:14 AM instead of 8 de enero de 2020 10:14.

However, switching the order of locale and tz, e.g.
dayjs('2020-01-08T15:14:59.741774+00:00') .tz('America/New_York') .locale('es') .format('LLL')
gives the correct result of 8 de enero de 2020 10:14.

I believe this is the result of the following line of code, which overrides the current locale:

const target = date.toLocaleString('en-US', { timeZone: timezone })

This is the intended behavior or is it something to be fixed to support the provided locale?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions