Mohamed Sahir
Mohamed Sahir

Reputation: 2543

How to do a format with moment js

why momemnt shows 12 hr as below code.

let x =moment("2018-12-11 00:00").format("hh:mm:ss");
console.log(x);

expected output: 00:00:00, Recieved : 12:00:00

stackblitz:https://stackblitz.com/edit/moment-85eraf?file=app/app.component.ts

Upvotes: 1

Views: 412

Answers (2)

Vadim Hulevich
Vadim Hulevich

Reputation: 1833

try .utc method and change hh to HH:

let x =moment.utc("2018-12-11 00:00").format("HH:mm:ss");

Upvotes: 1

Sølve
Sølve

Reputation: 4406

You have to change the lowercase hh to uppercase: HH in .format("hh:mm:ss");

hh is the 12-hour, while HH is the 24-hour format.

You can get more details in their docs

Upvotes: 3

Related Questions