how to convert Time format H:MM to HH:mm format if it is showing in single digit. For example I want to show 9:00 AM as 09:00 AM.
My input should be 9:00 AM and output should be 09:00 AM.
how to convert Time format H:MM to HH:mm format if it is showing in single digit. For example I want to show 9:00 AM as 09:00 AM.
My input should be 9:00 AM and output should be 09:00 AM.
var newDate = new Date();
console.log("0" + newDate.getHours());
Use Date()
. It might help you.
Moment.js (https://momentjs.com/) is normally my go-to library for Date parsing.
Not sure exactly what your output format is in full, but something like the following should do the trick:
moment("1/5/15 9:3:4", "D/M/YY h:m:s").format("DD/MM/YYYY hh:mm:ss") == "01/05/2015 09:03:04"