node.js event processing plug-ins use dateformat

Directly through the new Date out of time does not meet our habits, dateformar plug node.js can often deal of time, use the following
1 download dateformat dateformat install plug npm
2 dateformat module introduced in the js
3 variable import module

const template=require('art-template');
const path=require('path');
const dateformat=require('dateformat');
const views=path.join(__dirname,'view','06.art');
//导入模板变量,使处理函数是template里的一个方法
template.defaults.imports.dateformat=dateformat;
const html=template(views,{
    time:new Date(),
})
console.log(html);

4 Using the template in .art

{{dateformat(time,'yyyy-mm-dd HH:MM:ss')}}

The result is 2019-10-07 13:40:53

Published 17 original articles · won praise 0 · Views 426

Guess you like

Origin blog.csdn.net/weixin_44805161/article/details/102303049