function formatDate(time, flag) { const t = new Date(time); const tf = function(i){return (i < 10 ? '0' : '') + i}; const year = t.getFullYear(); const month = tf(t.getMonth() + 1); const day = tf(t.getDate()); const hour = tf(t.getHours()); const minute = tf(t.getMinutes()); //console.log( month + '月' + day + '日' + hour + ':' + minute); if(flag == 1) { return month + '月' + day + '日' + ' ' + hour + ':' + minute; }else if(flag == 2) { return year + '-' + month + '-' + day }else if(flag == 3){ return month + '-' + day + ' ' + hour + ':' + minute; } } module.exports.formatDate = formatDate; {{ item.description }} + {{ item.price }} - {{ item.price }}