One, JS get timestamp: The first method: var timestamp1 = date.parse (New Date ()); The second method: var timestamp2 = (new Date ()). ValueOf (); The third method: var Timestamp3 = new Date (). GetTime (); alert (TIMESTAMP1);//Results: 1372751992000alert (TIMESTAMP2);//Results: 1372751992066alert (Timestamp3);/results: 1372751992066 Note: The first obtained timestamp is to change the millisecond to 000, the second and third is to get the timestamp of the current millisecond. Second, timestamp format: function FormatDate (now) {var year = Now.getfullyear (), month = Now.getmonth () + 1, date = Now.getdate (), hour = Now.gethours (), minute = Now.getminutes (), second = Now.getseconds (); Return year + "-" + month + "-" + Date + "" + Hour + ":" + Minute + ":" + Second;} var d = new Date (); Alert (FormatDate (d));//2016-12-12 12-12-12
JavaScript gets timestamp, date formatting