new date()标准时间转yyyy-mm-dd hh:mm 24小时制
// 扩充js的内置对象Date方法 Object . assign ( Date . prototype , { switch ( time ) { let date = { "yy" : this . getFullYear ( ) , // 这里月份的key采用大写,为了区别分钟的key "MM" : this . getMonth ( ) + 1 , "dd" : this . getDate ( ) , "hh" : this . getHours ( ) , "mm" : this . getMinutes ( ) , "ss" : this . getSeconds ( ) } ; //输出年 y+:匹配1个到多个y,i:忽略大小写 if ( /(y+)/i . test ( time ) ) { time = time . replace ( RegExp . $ 1 , ( this . getFullYear ( ) + '' ) . substr ( 4 - RegExp . $ 1. length ) ) ; } //输出月、日、时、分、秒 Object . keys ( date ) . forEach ( function ( i ) { // "(" + i + ")"的结果是字符串"(i+)", // 只有写成"(" + i + ")"形式