Home > WeChat Applet > Mini Program Development > What should I do if the new Date() method of the applet fails?

What should I do if the new Date() method of the applet fails?

hzc
Release: 2020-06-29 10:54:52
forward
2860 people have browsed it

The iOS system has format requirements for the new Date() method in js

let dt = new Date("2019-07-24 19:57")
// dt会返回valid Date
Copy after login

The correct way to write it should be

let dt = new Date("2019/07/24 19:57")
Copy after login

In fact, most of the date formats in the process are 2019-07- 24, so in the actual application process, it is necessary to use regular expressions to preprocess the string

let tm = "2019-07-24 19:57"
let dt = new Date(tm.replace(/-/g,'/'))
Copy after login

During the development of the small program, a date conversion method was used, but it didn’t work on Apple’s mobile phone. I searched online. I just discovered this problem and recorded the

recommended tutorial: "WeChat Mini Program"

The above is the detailed content of What should I do if the new Date() method of the applet fails?. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:jianshu.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template