Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Safari Invalid date 问题 #7

Open
yinxin630 opened this issue Apr 24, 2019 · 0 comments
Open

Safari Invalid date 问题 #7

yinxin630 opened this issue Apr 24, 2019 · 0 comments

Comments

@yinxin630
Copy link
Owner

问题原因

用了非标准的时间字符串去 new Date(), 类似 '2019-04-24'

在 Chrome 中是没有问题的, 但是 Safari 中不行, 其它浏览器未测试

如何避免问题

应该使用标准的时间格式, 包括:

  • MM-dd-yyyy
  • yyyy/MM/dd
  • MM/dd/yyyy
  • MMMM dd, yyyy
  • MMM dd, yyyy

非标准时间转换

let time = '2019-04-24';
time = time.replace(/-/g, '/');
let date = new Date(time);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant