1 //字符串转成Time(dateDiff)所需方法 2 function stringToTime(string) { 3 var f = string.split(' ', 2); 4 var d = (f[0] ? f[0] : '').split('-', 3); 5 var t = (f[1] ? f[1] : '').split(':', 3); 6 return (new Date( 7 parseInt(d[0], 10) || null, 8 (parseInt(d[1], 10) || 1) - 1, 9 parseInt(d[2], 10) || null, 10 parseInt(t[0], 10) || null, 11 parseInt(t[1], 10) || null, 12 parseInt(t[2], 10) || null 13 )).getTime(); 14 }