js里面要用可以用伊尔表达式,循环是用js:
document.getElementById("${pj.pltime }").innerHTML = dateToGMT("${pj.pltime }");
<div class="order-info"> <p id="${pj.pltime}"> <script type="text/javascript"> function dateToGMT(strDate) { console.log("原始时间格式:" + strDate); var date = new Date(strDate); var y = date.getFullYear(); var m = date.getMonth() + 1; m = m < 10 ? ('0' + m) : m; var d = date.getDate(); d = d < 10 ? ('0' + d) : d; var h = date.getHours(); var minute = date.getMinutes(); minute = minute < 10 ? ('0' + minute) : minute; var str = y + "-" + m + "-" + d + " " + h + ":" + minute; console.log("转换时间格式:" + str); return "评论时间:" + str; } document.getElementById("${pj.pltime }").innerHTML = dateToGMT("${pj.pltime }"); </script> </p> </div>