日期格式化bug

This commit is contained in:
wuxw 2025-08-05 16:56:32 +08:00
parent 9a7ff0d166
commit afb2d325e5

View File

@ -36,11 +36,11 @@ const formatDate = date => {
const getDate = function getDate(strDate) { const getDate = function getDate(strDate) {
var st = strDate; var st = strDate;
var a = st.split(" "); //这个根据你的字符串决定如果中间为T则改T var a = st.split(" "); // 分割日期和时间部分
var b = a[0].split("-"); var b = a[0].split("-"); // 分割年、月、日
var c = a[1].split(":"); var c = a[1].split(":"); // 分割时、分、秒
var date = new Date(b[0], b[1], b[2], c[0], c[1], c[2]); var date = new Date(b[0], b[1] - 1, b[2], c[0], c[1], c[2]); // 月份减1
return date; return date;
}; };
/** /**