问题描述
Date 对象的 toLocaleString 方法在各浏览器下的返回值存在格式上的差异。
解决方案
要获得相同格式的时间字符串,请不要使用 Date.prototype.toLocaleString() 方法,可以通过分别使用 getFullYear、getMonth、getDate 和 getDay 分别获得各关键字符串并拼装。
Date 对象的 toLocaleString 方法在各浏览器下的返回值存在格式上的差异。
解决方案
要获得相同格式的时间字符串,请不要使用 Date.prototype.toLocaleString() 方法,可以通过分别使用 getFullYear、getMonth、getDate 和 getDay 分别获得各关键字符串并拼装。