Las marcas de tiempo de JavaScript y las cadenas de fecha convierten los códigos entre sí (súper simples)
<html xmlns = "http://www.w3.org/1999/xhtml"> <fead> <meta http-equiv = "content-type" content = "text/html; charset = utf-8"/> <script type = "text/javascript"> // obtiene el timestamp actual (in s) vAR) (date. Date ()); timestamp = timestamp/ 1000; // La marca de tiempo actual es: 1403149534console.log ("La marca de tiempo actual es:" + timestamp); // Obtener la marca de tiempo en un cierto formato var stringtime = "2014-07-10 10:21:12"; var timestamp2 = date.párse /1000; // 2014-07-10 La marca de tiempo de 10:21:12 es: 1404958872 Console.log (StringTime + "TimeStamp:" + TimeStamp2); // Cambie la hora actual a la cadena de tiempo de tiempo VAR VAR TIMESTAM = 1403058804; var NewDate = New Date (); Newdate.setTime (TimeStMeP3 * 1000); 2014 console.log (newdate.todateString ()); // mié, 18 de junio de 2014 02:33:24 GMT Console.log (newdate.togmtstring ()); // 2014-06-18T02: 33: 24.000zconsole.log (newdate.toisosstring ()); // 2014-06-18T02: 33: 24.000Z Console.log (newdate.tojson ()); // 18 de junio de 2014 console.log (newdate.tolocaledateString ()); // 18 de junio de 2014 a las 10:33:24 am Console.log (newdate.tolocalestring ()); // 10:33:24 AMM console.log (newdate.tolocaletiMeString ()); // miércoles 18 de junio de 2014 10:33:24 GMT+0800 (Tiempo estándar de China) Console.log (newdate.ToString ()); // 10:33:24 GMT+0800 (Tiempo estándar de China) Console.log (newdate.totimestring ()); 02:33:24 GMTconsole.log(newDate.toUTCString());Date.prototype.format = function(format) { var date = { "M+": this.getMonth() + 1, "d+": this.getDate(), "h+": this.getHours(), "m+": this.getMinutes(), "s+": this.getSeconds (), "Q+": Math.Floor ((this.getMonth ()+3) / 3), "S+": this.getMilliseConds ()}; if (/(y+)/i.test(Format)) {format = format.replace (regexp. $ 1, (this.getblyear () + '') .substr (4 - regexp. $ 1.length)); } for (var k en fecha) {if (new REGEXP ("(" + K + ")"). Test (Format)) {format = format.replace (regexp. $ 1, regexp. $ 1.length == 1? date [k]: ("00" + fecha [k]). Sustr ((" + fecha [k]).); }} formato de retorno;} console.log (newdate.format ('yyyy-mm-dd h: m: s')); </script>Lo anterior es el contenido completo del código de conversión de la marca de tiempo de JavaScript y la cadena de fecha (súper simple) que el editor le presenta. Espero que todos apoyen a Wulin.com ~