Skip to content

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.

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");