//js中使用new Date(str)创建时间对象不兼容firefox和ie的问题
//比如2016-01-29格式的时间字符串通过new Date()将不能得到正确的时间对象
//处理方式如下:
var endDate = '2016-01-29';
//方式一:Date.parse()
//字符串格式转换:2016-01-29转换为2016/01/29,来兼容firefox
endDate = endDate.replace("-", "/").replace("-", "/");//endDate.replace(/-/g,'/');
//将时间字符串先获取毫秒
var times = Date.parse(endDate);////返回毫秒
//转换为时间类型
endDate = new Date(times);
console.log(endDate);
//方式二,Date.UTC()
//字符串格式分割为年、月、日、时、分、秒的数组,来兼容firefox
var DateTime = startDate.split(" ");//日期和时间分割
var date = DateTime[0].split("-");
//转换毫秒
var times = Date.UTC(date[0],date[1],date[2]);//返回毫秒
//转换为时间类型
endDate = new Date(times);
console.log(endDate);
//最后:方式三
//可以不使用Date.parse('strDateTime')或Date.UTC(年,月,日,时,分,秒)(年、月是必需的),直接将参数给Date()构造函数
//Date()构造函数内部会模仿Date.parse('strDateTime')或Date.UTC(年,月,日,时,分,秒)进行转换
var times = new Date(endDate);//模仿Date.parse('strDateTime')
var times = new Date(date[0],date[1],date[2]);//模仿Date.UTC(年,月,日,时,分,秒)