时间转换

160 阅读1分钟

将标准时间转换为某种时间的格式

function formatDate() {
      var today = new Date();    
      return today.toLocaleString("zh-Hans-CN", {        
      // timeZone: ['UTC'],
        weekday: "long",
        hour12: false,       
         year: "numeric",        
         month: "2-digit",        
         day: "2-digit",        
         hour: "2-digit",        
         minute: "2-digit",        
         second: "2-digit"
      });
    }输出2018年06月27日星期三 10:09:19   function showingExpirationDate() {      
       var today = new Date();  
      return today.toISOString().substring(0,10)+ ' '+today.toTimeString().substring(0,9);
    }输出 2018-06-27 10:07:02


原文链接

http://www.imooc.com/wenda/detail/395292