Skip to content

toLocaleTimeString returns invalid time when using 24hr time format #50947

@michelnev

Description

@michelnev

Version

v20.9.0

Platform

FreeBSD freebsd 13.2-RELEASE-p4 FreeBSD 13.2-RELEASE-p4 GENERIC amd64

Subsystem

No response

What steps will reproduce the bug?

I tested on Linux as well in version v18.17.1 with the same result. Within node, simply execute the following script:

const event = new Date('2020-04-20T16:40:13.000Z');
console.log(event.toLocaleTimeString('en-US', { timeZone: 'Asia/Taipei', hour12: false}));

How often does it reproduce? Is there a required condition?

100% for the scenario described.

What is the expected behavior? Why is that the expected behavior?

Expect to see the following output:
00:40:13

What do you see instead?

Saw the following output on multiple host systems:
24:40:13

Additional information

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions