Este artigo descreve como o JS pode simplesmente obter e exibir a hora atual. Compartilhe -o para sua referência, como segue:
<! Doctype html> <html xmlns = "http://www.w3.org/1999/xhtml"> <head> <meta http-equiv = "content-type" content = "text/html; charset = gb232"/> <> Date (); var ano = agora.GetlyEar (); // ano var mês = agora.getmonth () + 1; // mês var dia = agora.getDate (); // dia var hh = agora.gethours (); // tempo var mm = agora.getminutes (); // 平 var relógio = ano +"-"; if (mês <10) relógio += "0"; relógio += mês +"-"; if (dia <10) relógio += "0"; relógio += dia +""; se (hh <10) relógio += "0"; mm; document.write (relógio); </script> </body> </html>
PS: Amigos interessados nas operações de tempo e data de JavaScript também podem se referir às ferramentas on -line deste site:
Ferramenta de conversão do UNIX Timestamp:
http://tools.vevb.com/code/unixtime
Inquérito de tempo online em todo o mundo:
http://tools.vevb.com/zhuanhuanqi/worldtime
Calendário perpétuo online:
http://tools.vevb.com/bianmin/wannianli
Calendário perpétuo da 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", "Resumo do Algoritmo e Habilidades de Traversal JavaScript" e "Resumo do Uso da Operação Matemática JavaScript"
Espero que este artigo seja útil para a programação JavaScript de todos.