//在开发过程中,有人会出现
日期:2020-1-1
小时分钟: 9:00
let ri = “2020-1-1”
let h = “9:00:00”
new Date(ri++“ ”+h);
安卓可以正常转化,而ios报异常
出现以上情况,可以这样解决以下异常
//判断如果是ios, 把’-‘转成’/’ yyyy/mm/dd
if ('ios' == platform) {
ri = ri.replace(/\-/g, '/');
if (h.startTime.length === 7) {
h = '0' + h;
}
}
let result = new Date(ri+h);
console.log(result);