这是尝试过的:
部分伪代码:
var hours = date1.getHours();
var minutes = date2.getMinutes();
if (hours.length == 1)
hours = "0" + hours;
if (minutes.length == 1)
minutes = "0" + minutes;
var time = hours + ':' + minutes;
有没有像格式化字符串函数这样的更聪明的方法,我可以说:
var minutes = date.getMinutes('mm');
var hours = date.getHours('hh');
所以它会自动添加零?