Welcome to my website, have a nice day!
Dream it, Do it, Make it!

怎么将UTC格式的日期格式化为字符串

代码如下:

Date.UTC(2015, 11, 1,21,37);
>1449005820000
new Date(1449005820000);
>Wed Dec 02 2015 05:37:00 GMT+0800 (中国标准时间)
new Date(1449005820000).toISOString().
  replace(/T/, ' ').      // replace T with a space
  replace(/\..+/, '')     // delete the dot and everything after
>"2015-12-01 21:37:00"

参考:How to format a date string in UTC

赞(0)
未经允许禁止转载:Ddmit » 怎么将UTC格式的日期格式化为字符串

评论 抢沙发

登录

找回密码

注册