blog icon indicating copy to clipboard operation
blog copied to clipboard

date

Open anjia opened this issue 6 years ago • 1 comments

var now = new Date()

now.toLocaleString()       // 2019/1/7 下午12:30:13
now.toLocaleDateString()   // 2019/1/7
now.toLocaleTimeString()   // 下午12:30:13

now.toDateString()    // Mon Jan 07 2019
now.toGMTString()     // Mon, 07 Jan 2019 04:30:13 GMT
now.toISOString()     // 2019-01-07T04:30:13.857Z
now.toJSON()          // 2019-01-07T04:30:13Z

now.toString()      // Mon Jan 07 2019 12:30:13 GMT+0800 (中国标准时间)
now.toTimeString()  // 12:30:13 GMT+0800 (中国标准时间)
now.toUTCString()   // Mon, 07 Jan 2019 04:30:13 GMT

anjia avatar Jan 07 '19 05:01 anjia

有兼容性问题:移动端,不同手机显示的值不同

new Date(time).toLocaleString()

anjia avatar Jan 22 '19 07:01 anjia