直接贴代码:
var expiretime = "2017-06-16 10:04:00";//后端是传字符串的格式var timeStrSplitArr = expiretime.split("T"); var yearMonthDate = timeStrSplitArr[0].split("-"); var hourMinuteSecond_miniSecond = timeStrSplitArr[1].split("."); var hourMinuteSecond = hourMinuteSecond_miniSecond[0]; var year = parseInt(yearMonthDate[0]); var month = parseInt(yearMonthDate[1]) - 1; var date = parseInt(yearMonthDate[2]); hourMinuteSecond = hourMinuteSecond.split(":"); var hour = parseInt(hourMinuteSecond[0]); var minute = parseInt(hourMinuteSecond[1]); var second = parseInt(hourMinuteSecond[2]); var miniSecond = parseInt(hourMinuteSecond_miniSecond[1]); var endDate = new Date(year, month, date, hour, minute, second, miniSecond);
时间: 2024-12-12 11:56:31