Solve the problem that the WeChat applet Date.parse() obtains the timestamp and displays it as NaN on IOS

Date.parse("2022-04-08 12:00") real machine debugging, displayed as NaN,

IOS just displays abnormally. However, Android machines are fine.

You will know later by querying:

The IOS system does not support the time format of 2022-04-08, which causes this problem.

IOS only recognizes the format 2022/04/08

var data = '2018-03-09 12:00:00'
var format = data.replace(/-/g, '/')
var countDown = Date.parse(new Date(format))
this.moment(startDate).format('YYYY/MM/DD HH:mm')

Need to be used after introducing moment

main.js

import moment from 'moment'

Vue.prototype.moment = moment

Guess you like

Origin blog.csdn.net/qq_42351675/article/details/124251051