Reputation: 3
I am trying to convert time from a date and was testing why it was always coming out as 11:10. I set up this simple test to see if it was still converting the same way and it is. This test gives start time formatted as 11:10. It should be 11:59.
var testDate = "11:59"
console.log("start time formatted", moment(testDate, ["h:mm"]).format("H:MM"));
console.log("start time", testDate);
Upvotes: 0
Views: 42
Reputation: 3
This works, MM and mm are differences for month and minutes!
var testDate = "11:50"
console.log("start time formatted", moment(testDate, ["h:m"]).format("H:mm"));
console.log("start time", testDate);
Upvotes: 0
Reputation: 5262
I believe MM
is numeric format for month which is current month October (10). Try to change it to mm
like following code.
moment(testDate, ["h:mm"]).format("H:mm");
Upvotes: 1