Blogger Information
Blog 47
fans 0
comment 2
visits 102734
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
js解决ios时间new Date()时显示NaN
拾一枝樱花的博客
Original
4368 people have browsed it
  1. 1.var newDate = new Date("2018-12-28 15:00:00")
  2. 这种获取的时间在安卓手机上显示是正常的,在苹果手机上显示NaN
  3. 2.var newDate = new Date("2018/12/28 15:00:00")
  4. 这种获取的时间在安卓和苹果手机上都显示正常
  5. 3.转换时间格式 .replace(/-/g, "/")
  6. var newDate=new Date("2020-01-13 13:56:09".replace(/\-/g,"/")).getTime();
  7. 【补充】
  8. 1、经苹果手机测试,如果"只有日期不含时间的字符串"转换日期时,不管用“-”还是用“/”分隔都能顺利转换成日期,如果含“时间”,即必须要用“/”分隔;
  9. 2、如果时间字符串包含“T”和"Z", 不管用"-"或“/”分隔,都能成功转换出时间,但会加上时区的差值

Statement of this Website
The copyright of this blog article belongs to the blogger. Please specify the address when reprinting! If there is any infringement or violation of the law, please contact admin@php.cn Report processing!
All comments Speak rationally on civilized internet, please comply with News Comment Service Agreement
0 comments
Author's latest blog post