js日期溢出

//有溢出问题
function js_patch_getdate(stime) {
	var datetime = new Date();
	datetime.setFullYear(parseFloat(stime.substr(0, 4)));
	datetime.setMonth(parseFloat(stime.substr(4, 2) - 1));
	datetime.setDate(parseFloat(stime.substr(6, 2)));
	datetime.setHours(parseFloat(stime.substr(8, 2)));
	datetime.setMinutes(parseFloat(stime.substr(10, 2)));
	datetime.setSeconds(parseFloat(stime.substr(12, 2)));
	return datetime;
}
//解决溢出问题
function js_patch_getdate(stime) {
	var datetime = new Date(
			parseFloat(stime.substr(0, 4)),
			parseFloat(stime.substr(4, 2) - 1),
			parseFloat(stime.substr(6, 2)),
			parseFloat(stime.substr(8, 2)),
			parseFloat(stime.substr(10, 2)),
			parseFloat(stime.substr(12, 2)));
	return datetime;
}

你可能感兴趣的:(JavaScript)