var option ={
time: '2017-08-31 16:31:02',
type: ['/', '/'],
formatYear: false,
formatDate: true
}
time为需要转换的时间,格式可以是时间戳or时间字符串
type为需要转换的格式类型,需是array,如需显示2017年08月01日格式,则传['年','月','日'],如需显示2017-08-01格式,则传['-','-','-'],如需显示2017/08/01格式,则传['/','/']
formatYear为是否显示年月日,需是bool,true显示,false不显示
formatDate为是否显示时分秒,需是bool,true显示,false不显示
formatYear && formatYear 同时为true,则显示年月日 时分秒默认这两个值可以不传
step npm i lotusformat --save or yarn add lotusformat
var forMatDate = require("lotusdateformat");
1.显示时分秒 如:11:29:10
forMatDate({
formatDate: true
});
2.显示年月日 如:2017-08-31
forMatDate({
time: '2017-08-31 16:31:02',
formatYear: true
});
3.显示年月日 如:2017年08月31日
forMatDate({
time: '2017-08-31 16:31:02',
type: ['年', '月', '日'],
formatYear: true
});
4.显示年月日时分秒 如:2017/08/31 16:31:02
forMatDate({
time: '2017-08-31 16:31:02',
type: ['/', '/']
});
5.显示年月日时分秒 如:2017-09-01 11:29:10
forMatDate();
6.显示年月日时分秒 如:2017年09月01日 16:31:02
forMatDate({
time: '2017-9-1 16:31:02',
type: ['年', '月', '日']
});