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

【兼容性】之ios时间Date兼容性问题 #4

Open
yihan12 opened this issue Jul 6, 2022 · 0 comments
Open

【兼容性】之ios时间Date兼容性问题 #4

yihan12 opened this issue Jul 6, 2022 · 0 comments
Labels
【兼容性】 兼容性系列

Comments

@yihan12
Copy link
Owner

yihan12 commented Jul 6, 2022

一、概述

ios时间转时间戳出现invalid Date
moment在ios时间转时间戳出现invalid Date

1.IOS上getTime(),getFullYear()等方法返回NaN
2.moment处理类似 2020/1/1的格式会invalid Date

二、解决

1

new Date("2018-02-15 20:30:00".replace(/-/g,'/')).getTime();
new Date("2018-02-15 20:30:00".replace(/-/g,'/')).getFullYear();

2

//moment使用2020/02/01的正规格式进行处理
moment('2018-02-15') // ios不支持
moment('2018/02/15') // 需要转成此形式

ios时间兼容性问题,ios只兼容斜杠格式的时间(2020/09/29),需要用replace(/-/g, "/")将时间转化为ios兼容的格式。

兼容性系列

主要是日常业务代码问题整理。

后续会一直更新,希望各位看官不要吝啬手中的赞。

❤️ 感谢各位的支持!!!

❤️ 如果有错误或者不严谨的地方,请务必给予指正,十分感谢!!!

❤️ 喜欢或者有所启发,欢迎 star!!!

@yihan12 yihan12 changed the title ios时间Date兼容性问题 【兼容性】之ios时间Date兼容性问题 Jul 6, 2022
@yihan12 yihan12 added the 【兼容性】 兼容性系列 label Jul 7, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
【兼容性】 兼容性系列
Projects
None yet
Development

No branches or pull requests

1 participant