Company logo
  • Jobs
  • Bootcamp
  • About Us
  • For professionals
    • Home
    • Jobs
    • Courses
    • Questions
    • Teachers
    • Bootcamp
  • For business
    • Home
    • Our process
    • Plans
    • Assessments
    • Payroll
    • Blog
    • Sales
    • Calculator

0

103
Views
why is time format getting changed for 00:00:00 time in UTC 24 hour format to 24:00:00

I have the date as:

var date = new Date('2021-08-25T00:00:00.000+00:00');

I am formatting time as:

 time = date.toLocaleTimeString('en-Us', {
          hour12: false,
          hour: '2-digit',
          minute: '2-digit',
          second: '2-digit',
          timeZone: 'UTC',
        });

Why the time is getting changed to 24:00:00 instead of 00:00:00. And how can i have it as 00:00:00

7 months ago · Juan Pablo Isaza
1 answers
Answer question

0

Using en-Gb fixes it.

var date = new Date('2021-08-25T00:00:00.000+00:00');

let time = date.toLocaleTimeString('en-Gb', {
          hour12: false,
          hour: '2-digit',
          minute: '2-digit',
          second: '2-digit',
          timeZone: 'UTC',
        });
        
 console.log(time);

7 months ago · Juan Pablo Isaza Report
Answer question
Find remote jobs