const add0 = function(val) {
	return m < 10 ? '0' + m : m;
}
/**
 * format
 * @param {String/Number} time 时间戳 或者 正确的时间字符
 * @param {Number} type 返回的格式类型  
 */
export default function(time, type = 1) {
	time = new Date(time);
	var y = time.getFullYear();
	var m = time.getMonth() + 1;
	var d = time.getDate();
	var h = time.getHours();
	var mm = time.getMinutes();
	var s = time.getSeconds();
	switch (type) {
		case 2:
			return `${y}-${add0(m)}-${add(d)}`
		default:
			return `${y}-${add0(m)}-${add(d)} ${add0(h)}:${add0(mm)}:${add0(s)}`
	}
}
