Jquery converts the date and time type into the desired format.
1/** 2 * example: change the current time to xx, var date = new Date (); (to convert a given time to this format: var time = "2017-3-6 10:30:30" var date = new Date (time) 3 * var nowMs = date. getTime (); 4 * var currentTime = format ("MM dd, yyyy, HH, mm, ss seconds", nowMs ); 5*6 * @ param format the desired time format is "yyyy-MM-dd HH: mm: ss" (yyyy: indicates the year, MM: indicates the month, dd indicates the day, HH indicates the time, mm indicates the minute, ss indicates the second) 7 * @ param time milliseconds 8 * @ returns {* | string | void} 9 */10 var format = function (Format, time) {11 var t = new Date (time); 12 // Adding zero 13 var tf = function (I) {14 return (I <10? '0': '') + i15}; 16 return format. replace (/yyyy | MM | dd | HH | mm | ss/g, function (a) {17 switch (a) {18 case 'yyyy': 19 return tf (t. getFullYear (); 20 break; 21 case 'mm': 22 return tf (t. getMonth () + 1); 23 break; 24 case 'mm': 25 return tf (t. getMinutes (); 26 break; 27 case 'dd': 28 return tf (t. getDate (); 29 break; 30 case 'hh': 31 return tf (t. getHours (); 32 break; 33 case 'ss': 34 return tf (t. getSeconds (); 35 break; 36} 37}) 38}