IOS踩坑之旅(一:JavaScript中Date对象在IOS中的坑)

1,673 阅读1分钟

Date 对象

ate 对象用于处理日期与时间。

创建 Date 对象: new Date()

以下四种方法同样可以创建 Date 对象:

var d = new Date(); // 当前日期和时间
var d = new Date(milliseconds); // milliseconds指距离 1970 年 1 月 1 日至指定日期的毫秒数
var d = new Date(dateString);
var d = new Date(year, month, day, hours, minutes, seconds, milliseconds);

以上四种方法都可以在IOS系统中创建时间,其中第三种var d = new Date(dateString)是本篇文章的主角。

dateString

开发中我们常用的日期格式包含以下两种格式:'yyyy-MM-dd hh:mm:ss'和'yyyy/MM/dd hh:mm:ss'

兼容性

yyyy-MM-dd hh:mm:ssyyyy/MM/dd hh:mm:ss
chormeyesyes
IEyesyes
edgeyesyes
Android webviewyesyes
Chrome for Androidyesyes
Safari on iOSnoyes

IOS 踩坑之旅(二:v-for: number)