Recently done a project, from the background query to date data to the foreground JS after the traversal is displayed with "14" the number of milliseconds, just beginning to use "SimpleDateFormat" class processing, the results are not displayed. Later looked up a bit of information, feeling is actually very simple, the following to share their own methods for reference.
1. Number of milliseconds to display
2. Working with previous styles
3. The style after processing
1 Date.prototype.toLocaleString = function () {2 return this.getfullyear () + "-" + (THIS.G Etmonth () + 1) + "-" + this.getdate () + "" + this.gethours () + ":" + this.getminutes () + ":" + this.getseconds (); 3};4 5Successfunction(data) {6 varStr= ""; 7 varLength =data.length;8 for(vari=0;i<length;i++){ 9 //Str + = ' <tr><td> ' +data[i].roleid+ ' </td><td> ' +data[i].rolename+ ' </td><td> ' +data[i].remarks+ ' </td><td> ' +data[i].createby+ ' </td><td> ' +data[i].createdate+ ' </td ><td> ' +data[i].updateby+ ' </td><td> ' +data[i].updatedate+ ' </td><td> ' +data[i]. status+ ' </td></tr> ';TenDate.prototype.toLocaleString =function() { One return This. getFullYear () + "-" + ( This. GetMonth () + 1) + "-" + This. GetDate () + "" + This. GetHours () + ":" + This. getminutes () + ":" + This. getseconds (); A }; -Str + = "<tr>" + -"<td class=\" Tbody_check\ ">" + the"<span class=\" Check\ ">" + -"<input type=\" checkbox\ "value=\" "+data[i].roleid+" \ "name=\" checkbox\ ">" + -"</span>" + -"</td>" + +"<td>" +data[i].roleid+ "</td>" + -"<td>" +data[i].rolename+ "</td>" + +"<td>" +data[i].remarks+ "</td>" + A"<td>" +data[i].createby+ "</td>" + at"<td>" +new Date (data[i].createdate). toLocaleString ()+ "</td>" + -"<td>" +data[i].updateby+ "</td>" + -"<td>" +new Date (data[i].updatedate). toLocaleString ()+ "</td>" + -"<td>" +data[i].status+ "</td>" + -"</tr>"; - } in$ ("#rolelist"). HTML (STR); -}
How to convert milliseconds into a specified datetime format in JS