Artikel ini menjelaskan bagaimana JS dapat memperoleh dan menampilkan waktu saat ini. Bagikan untuk referensi Anda, sebagai berikut:
<! Doctype html> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http--equiv = "content" content = "Text/html; charset = gb2312"/<-type "sekarang) </Text/html; charset = gb2312"/content lute> titleer> sekarang/ht/html; charset = gb2312 "/> <typeer> saat ini =" Text/html; charset = gb2312 "/<type> tahun = sekarang.getlyear (); // tahun var bulan = now.getMonth () + 1; // bulan var day = now.getDate (); // day var hh = now.getHours (); // waktu var mm = now.getMinutes (); // 平 var jam = tahun +"-"; if (bulan <10) jam += "0"; jam += bulan +"-"; if (hari <10) jam += "0"; jam += hari +""; if (hh <10) jam += "0"; jam += hh +":"; if (mm <10) jam += 0 '; mm; document.write (clock); </script> </body> </html>
PS: Teman yang tertarik dengan operasi waktu dan tanggal javascript juga dapat merujuk pada alat online situs ini:
Alat Konversi Timestamp UNIX:
http://tools.vevb.com/code/unixtime
Pertanyaan waktu online di seluruh dunia:
http://tools.vevb.com/zhuanhuanqi/worldtime
Kalender abadi online:
http://tools.vevb.com/bianmin/wannianli
Kalender Perpetual Web:
http://tools.vevb.com/bianmin/webwannianli
For more information about JavaScript, please check this site's special topics: "Summary of JavaScript Time and Date Operation Skills", "Summary of JavaScript Switching Effects and Skills", "Summary of JavaScript Search Algorithm Skills", "Summary of JavaScript Animation Special Effects and Skills", "Summary of JavaScript Errors and Debugging Skills", "Summary of JavaScript Data Structures and Algorithm Skills", "Ringkasan Algoritma dan Keterampilan Traversal Javascript" dan "Ringkasan Penggunaan Operasi Matematika JavaScript"
Saya harap artikel ini akan membantu pemrograman JavaScript semua orang.