后端时间转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);

 

posted on 2017-06-16 17:36  wts_crazy  阅读(156)  评论(0编辑  收藏  举报