JS date转字符串(格式:yyyy-MM-dd HH:mm:ss)
/**
* @description 将date转为字符串:yyyy-MM-dd HH:mm:ss格式
* @author fzg
*/
export const formatDate = (date) => {
var Y = date.getFullYear();
var M = date.getMonth() + 1;
var D = date.getDate();
var hour = date.getHours();
var minute = date.getMinutes();
var second = date.getSeconds();
return Y + '-' + (M < 10 ? ('0' + M) : M) + '-' + (D < 10 ? ('0' + D) : D) + ' ' + (hour < 10 ? ('0' + hour) :
hour) + ':' + (minute < 10 ? ('0' + minute) : minute) + ':' + (second < 10 ? ('0' + second) : second);
}