JavaScript前端去除‘T’

当在开发过程中,如果数据库(这里使用的是SQL Server)数据库时,在获取当前时间时,中间带有“T”,去掉“T”,并进行了襄阳的方法封装。

//获得年月日时分秒
//传入日期//例:2020-10-27T14:36:23
var timeFormatSeconds = function(time) {
		var d = time ? new Date(time) : new Date();
		var year = d.getFullYear();
		var month = d.getMonth() + 1;
		var day = d.getDate();
		var hours = d.getHours();
		var min = d.getMinutes();
		var seconds = d.getSeconds();

		if (month < 10) month = '0' + month;
		if (day < 10) day = '0' + day;
		if (hours < 0) hours = '0' + hours;
		if (min < 10) min = '0' + min;
		if (seconds < 10) seconds = '0' + seconds;

		return (year + '-' + month + '-' + day + ' ' + hours + ':' + min + ':' + seconds);
}

去前:2020-10-27T14:36:23

去后:2020-10-27 14:36:23