Skip to content
Advertisement

moment js time formatting with custom time format as inputs

input format can be, hh:mm OR hh OR hh:mm:ss OR hh:mm A/hh A/hh:mm:ss how it can be formatted on same inline as “hh:mm:ss A” format.

How can we format using moment js. Or its not feasible input for moment js time formatting.

Advertisement

Answer

It is possible with the Format method

DEMO

import moment from "moment";

let date = new Date();
let time = date.getTime();

moment(time).format("hh:mm:ss A");
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement