const DateParse = {
/**
* 将GMT格式的时间转为数据库兼容的Date格式
* gmt => GMT格式的时间
* long => 是否长时间(包含时分秒), 可不填(默认值:true), 选填:false
* Wed Dec 01 2018 00:00:00 GMT+0800 (中国标准时间) => 2018-12-01 00:00:00 或 2018-12-01
*/
formatGMT: ( gmt, long ) => {
long = false === long ? false : true
let date = new Date(gmt);
let m = (date.getMonth() + 1), mm = '-' + (m < 10 ? '0' + m : m);
let d = date.getDate(), dd = '-' + (d < 10 ? '0' + d : d);
let h = date.getHours(), hh = ' ' +(h < 10 ? '0' + h : h);
let i = date.getMinutes(), ii = ':' +(i < 10 ? '0' + i : i);
let s = date.getSeconds(), ss = ':' +(s < 10 ? '0' + s : s);
return date.getFullYear() + mm + dd + (long?(hh + ii + ss):'')
}
}
function
getWeek(dateString){
var
date;
if
(isNull(dateString)){
date =
new
Date();
}
else
{
var
dateArray = dateString.split(
"-"
);
date =
new
Date(dateArray[0], parseInt(dateArray[1] - 1), dateArray[2]);
}
return
"星期"
+
"日一二三四五六"
.charAt(date.getDay());
};