- in IE edge, the time string obtained with toLocaleDateString behaves strangely. Ask for advice
the code is as follows:
var tableDateValue = [
new Date(new Date().getTime() - 3600 * 1000 * 24 * 8).toLocaleDateString("zh-Hans-CN").replace(//g, "").replace(/\/||/g, "-"),
new Date(new Date().getTime() - 3600 * 1000 * 24 * 1).toLocaleDateString("zh-Hans-CN").replace(//g, "").replace(/\/||/g, "-")
];
console.log(tableDateValue[0]);
console.log(tableDateValue[1]);
var params = {
startTime: specifyTime(tableDateValue[0]),
endTime: specifyTime(tableDateValue[1])
};
console.log(params);
function specifyTime(time) {
var arr = time.split("-");
console.log(arr);
console.log(typeof arr[1]);
console.log(arr[1]);
console.log(arr[1].length);
console.log(Number(arr[1]));
if (arr[1].length < 2 && Number(arr[1]) < 10) {
arr[1] = "0" + arr[1];
}
console.log(arr[1]);
if (arr[2].length < 2 && Number(arr[2]) < 10) {
arr[2] = "0" + arr[2];
}
return arr.join("-");
}
arr[1].length 3 IE9IE10IE edge~~