2.js将Date对象转换成“2018-05-10”字符串格式化的时间

 1       //拼接0
 2          $cms.joint0 = function(val) {
 3              if (val < 10) return "0"+val;
 4              return val;
 5          }
 6          //时间格式化
 7          $cms.formatDate = function(date) {
 8           9                 return date.getFullYear() + "-" + (date.getMonth() + 1) + "-" + date.getDate() + " " + 
10                 $cms.joint0(date.getHours()) + ":" + $cms.joint0(date.getMinutes()) + ":" + $cms.joint0(date.getSeconds());
11             13          }
14        
$cms.formatDate方法的参数date为Date类型的对象,
$cms.formatDate返回的就是一个格式化为字符串的时间。
原文地址:https://www.cnblogs.com/WNof11020520/p/9018195.html