JavaScript -Zeitstempel und Datumszeichenfolgen konvertieren Codes miteinander (super einfach)
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><script type="text/javascript">// Get the current timestamp (in s) var timestamp = Date.parse(new Date ()); Zeitstempel = Zeitstempel/ 1000; // Der aktuelle Zeitstempel ist: 1403149534console.log ("Der aktuelle Zeitstempel lautet:" + Zeitstempel); // Erhalten Sie den Zeitstempel TimeStamp2 = Datedamp2 = DateP2 = Datum. /1000; // 2014-07-10 Der Zeitstempel von 10:21:12 lautet: 1404958872 Konsole.log (StringTime + "Timestamp:" + Timestamp2); // Die aktuelle Zeit ändere die aktuelle Zeit auf das Zeitformat String var timestamp3 = 1403058804; 2014 Console.log (newdate.todatestring ()); // Mi, 18. Juni 2014 02:33:24 GMT Console.log (newdate.togmtstring (); // 2014-06-18t02: 33: 24.000zconsole.log (newdate.toosString (); // // // // // // // // ////sisoss (); // // // //// 2014-06-18T02: 33: 24.000Z Console.log (newdate.tojson ()); // 18. Juni 2014 Konsole.log (newdate.tolocaledatestring (); // 18. Juni 2014 um 10:33:24 Uhr console.log (newdate.tolocalestring (); console.log (newdate 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. } für (var k in Datum) {if (new Regexp ("(" + k + ")"). test (format)) {format = format.replace (regexp. $ 1, regexp. }} return format;} console.log (newdate.format ('yyyy-mm-dd h: m: s')); </script>Das obige ist der vollständige Inhalt des JavaScript -Zeitstempels und des Datumsstring -Conversion -Code (Super Simple), das Ihnen vom Editor zur Verfügung gestellt wurde. Ich hoffe, jeder unterstützt Wulin.com ~