JavaScript Timestamps and Date Strings Convert Codes satu sama lain (super sederhana)
<html xmlns = "http://www.w3.org/1999/xhtml"> <adept> <meta http-equiv = "content-type" content = "text/html; charset = utf-8"/> <script type = "Text/Javascript"> Get The Date = Get The SCRITED (SCRIP SCRIME = "JAVASCRIPT"> Date ()); timestamp = timestamp/ 1000; // cap waktu saat ini adalah: 1403149534Console.log ("Cap waktu saat ini adalah:" + timestamp); // Dapatkan timestamp dalam format waktu tertentu var stringtime = "2014-07-10 10:21:12"; var timestamp2 = date. Date. Date. Date. Date. Date. Date. Date. Date. DATE (DATE (2014-2. /1000; // 2014-07-10 Timestamp dari 10:21:12 adalah: 1404958872 Console.log (StringTime + "Timestamp:" + Timestamp2); // Ubah waktu saat ini ke waktu saat ini; Jum-Jountamp3 = 140305804; var var Newdate = tanggal baru (); 2014 console.log (newDate.todateString ()); // Wed, 18 Jun 2014 02:33:24 gmt console.log (newdate.togmtstring ()); // 2014-06-18t02: 33: 24.000zconsole.log (Newdate.toisssstring02: 33: 24.000 2014-06-18T02: 33: 24.000z Console.log (newdate.tojson ()); // 18 Juni 2014 Console.log (newdate.tolocaledateString ()); // 18 Juni 2014 di 10:33:24 konsol. console.log (newDate.Tolocaletimestring ()); // Rab 18 Jun 2014 10:33:24 GMT+0800 (China Standard Time) Console.log (newdate.tostring (); // 10:33:24 GMT+0800 (China Standard Time) Console.log. 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.getlyear () + '') .substr (4 - regexp. $ 1.length)); } untuk (var k dalam tanggal) {if (regexp baru ("(" + k + ")"). Test (format)) {format = format.replace (Regexp. $ 1, Regexp. $ 1.length == 1? Tanggal [k]: ("00" + tanggal [k]). Subtr ("" + Tanggal (K]).). Tanggal). }} return format;} console.log (newDate.format ('yyyy-mm-dd h: m: s')); </skrip>Di atas adalah konten lengkap dari Cap Waktu JavaScript dan Kode Konversi String Tanggal (Super Sederhana) kepada Anda oleh editor. Saya harap semua orang akan mendukung wulin.com ~