From 454566a524d25778a5f3e890aa05a93bcbca3812 Mon Sep 17 00:00:00 2001 From: dandan Date: Thu, 28 Apr 2022 11:45:12 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=A2=9E=E5=8A=A0=E6=97=A5=E6=9C=9F?= =?UTF-8?q?=E6=A0=BC=E5=BC=8F=E5=8C=96=E5=B7=A5=E5=85=B7=E5=AF=B9ios?= =?UTF-8?q?=E7=9A=84=E5=85=BC=E5=AE=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- uview-ui/libs/function/timeFormat.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/uview-ui/libs/function/timeFormat.js b/uview-ui/libs/function/timeFormat.js index 0372f2f1..896ddee5 100644 --- a/uview-ui/libs/function/timeFormat.js +++ b/uview-ui/libs/function/timeFormat.js @@ -28,7 +28,9 @@ function timeFormat(dateTime = null, fmt = 'yyyy-mm-dd') { if (!dateTime) dateTime = Number(new Date()); // 如果dateTime长度为10或者13,则为秒和毫秒的时间戳,如果超过13位,则为其他的时间格式 if (dateTime.toString().length == 10) dateTime *= 1000; - let date = new Date(dateTime); + // ios的Date不识别'-', 替换成'/'兼容 + const { platform } = uni.getSystemInfoSync(); + let date = new Date(typeof dateTime === 'string' && platform === 'ios' ? dateTime.replace(/-/g, "/") : dateTime); let ret; let opt = { "y+": date.getFullYear().toString(), // 年