欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

标准时间转换

程序员文章站 2024-03-18 18:33:28
...
  function timeChange (dateStr) {
      let endDate,
          date = new Date(dateStr);
      endDate = date.getFullYear() + '-' 
              + (date.getMonth() + 1) + '-' 
              + date.getDate() + ' ' 
              + date.getHours() + ':' 
              + date.getMinutes() + ':'
              + date.getSeconds(); 
      return endDate;
  }
  timeChange(Thu Dec 14 2017 11:50:34 GMT+0800 (中国标准时间); 
  =>2017-12-1 11:50:34
相关标签: 时间转换