Chartjs-How to chnage this value theHour[0].times into time format (HH:mm) using moment.js

0👍

Convert the number to date and format it to “HH:mm”

var theHour = [3,15,16];
console.log(moment(new Date(0, 0, 0, theHour[0], 0, 0, 0)).format("HH:mm"));
console.log(moment(new Date(0, 0, 0, theHour[1], 0, 0, 0)).format("HH:mm"));
console.log(moment(new Date(0, 0, 0, theHour[2], 0, 0, 0)).format("hh:mm A"));
<script src="https://momentjs.com/downloads/moment.js"></script>

Leave a comment