Reputation: 5448
Hi I have an Handlebar helper call findHour that will return the hour as hh:mm but for 2:4 (2hrs40) it doesn't add the 0 at the end of it.
var heure_intervention = "2000-01-01T07:04:57Z"
Handlebars.registerHelper( "findHour", function ( heure_intervention ){
a= new Date(heure_intervention);
return (a.getHours() +":"+ a.getMinutes());
});
Upvotes: 0
Views: 35
Reputation: 2954
Try this solution:
...
return ( ( '0' + a.getHours() ).slice(-2) +":"+ ( '0' + a.getMinutes() ).slice(-2));
Upvotes: 1