其他分享
首页 > 其他分享> > js获取日期以及转换日期格式

js获取日期以及转换日期格式

作者:互联网

 

 

//js  
  var Date = new Date();
    console.log(Date) //Wed Jun 08 2022 10:36:47 GMT+0800 (中国标准时间)
    console.log(Date.toISOString()) //2022-06-08T02:36:57.025Z
    console.log(Date.toDateString()) //Wed Jun 08 2022
    console.log(Date.toLocaleDateString()) //2022/6/8
    console.log(Date.toLocaleString()) //2022/6/8 上午10:37:40
    console.log(Date.toLocaleTimeString()) //上午10:37:57
    console.log(Date.toJSON()) //2022-06-08T02:38:04.848Z
    console.log(Date.toUTCString()) //Wed, 08 Jun 2022 02:38:15 GMT
    console.log(Date.toTimeString()) //10:38:36 GMT+0800 (中国标准时间)
    //下面是时间戳(精确到毫秒)
    console.log(Date.getTime()) //1654656120739
    console.log(Date.valueOf()) //1654656120739

 

标签:10,console,log,Wed,js,日期,2022,Date,格式
来源: https://www.cnblogs.com/gyw1996/p/16355385.html