Este artículo describe cómo JS puede simplemente obtener y mostrar la hora actual. Compártelo para su referencia, como sigue:
<! Doctype html> <html xmlns = "http://www.w3.org/1999/xhtml"> <fead> <meta http-equiv = "content-type" content = "text/html; charset = gb2312"/> <title> actual </title> </healt> </head> Date (); var año = ahora.getblyear (); // año var mes = ahora.getMonth () + 1; // mes var day = ahora.getDate (); // día var hh = ahora.gethours (); // Time var mm = ahora.getminutes (); // 平 var clock = año +"-"; if (mes <10) reloj += "0"; reloj += mes +"-"; if (día <10) reloj += "0"; reloj += day +""; if (hh <10) reloj += "0"; reloj += hh +":"; if (mm <10) Rechan += '0 "; mm; document.write (reloj); </script> </body> </html>
PD: Los amigos interesados en las operaciones de hora y fecha de JavaScript también pueden referirse a las herramientas en línea de este sitio:
Herramienta de conversión de la marca de tiempo UNIX:
http://tools.vevb.com/code/unixtime
Consulta de tiempo en línea en todo el mundo:
http://tools.vevb.com/zhuanhuanqi/worldtime
Calendario perpetuo en línea:
http://tools.vevb.com/bianmin/wannianli
Calendario perpetuo 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", "Resumen del algoritmo y habilidades de traversal de JavaScript" y "Resumen del uso de la operación matemática de JavaScript"
Espero que este artículo sea útil para la programación de JavaScript de todos.