首页 > 代码库 > 后端时间转js时间,主要用于取倒计时

后端时间转js时间,主要用于取倒计时

直接贴代码:

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);

 

后端时间转js时间,主要用于取倒计时