Could moment.js be used to format var timeValue = '65'
into 01:05
? While easier to format as ('HH:MM:SS'), passing a variable as 65 and converting it into ('mm:ss') results in '01:00' instead of '01:05'.
Check it out
<div id="app">
<p>
The time is {{roomTime}}
</p>
<br/>
<p>
How can we display 01:05 instead of 01:00
</p>
</div>
Procedure
new Vue({
el: "#app",
data() {
return{
roomTime: '',
}
},
mounted: function(){
var timeValue = '65'; /** Since 65 equals 1 minute and 5 seconds **/
var formatTime = moment(timeValue).format("MM:SS");
/** Is there a way to have 65 displayed as 01:05 **/
this.roomTime = formatTime;
},
methods: {
toggle: function(todo){
todo.done = !todo.done
}
}
})
Here's my code snippet on JSFIDDLE