each customer, i in customers
tr
td #{timeConverter(customer.joiningDate)}
function timeConverter(UNIX_timestamp){
var a = new Date(UNIX_timestamp * 1000);
var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];
var year = a.getFullYear();
var month = months[a.getMonth()];
var date = a.getDate();
var hour = a.getHours();
var min = a.getMinutes();
var sec = a.getSeconds();
var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;
return time;
}
答案 0 :(得分:0)
尝试一下:
each customer, i in customers
tr
script.
var x;
x=timeConverter(customer.joiningDate);
td #{x}
答案 1 :(得分:0)
我找到了答案。我为该函数创建了一个路由,初始化了一个全局变量,并在前端使用了它。
答案 2 :(得分:-1)
将此添加为第一行:
- var timeConverter = function (UNIX_timestamp){ var a = new Date(UNIX_timestamp * 1000);var months = ['Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec'];var year = a.getFullYear();var month = months[a.getMonth()];var date = a.getDate();var hour = a.getHours();var min = a.getMinutes();var sec = a.getSeconds();var time = date + ' ' + month + ' ' + year + ' ' + hour + ':' + min + ':' + sec ;return time;}
在此行下方添加您的PUG代码
doctype html html 头 标题 我的编PUG 身体 [{joiningDate:new Date()}]中的每个客户,
TR td#{timeConverter(customer.joiningDate)}
然后运行:)