Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
- <html xmlns="http://www.w3.org/1999/xhtml">
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>Horas em tempo real com javascript!</title>
- <script>
- function showTime(){
- var time = new Date();
- var hour = time.getHours();
- var minute = time.getMinutes();
- var second = time.getSeconds();
- if(hour<10) hour = "0"+hour;
- if(minute<10) hour = "0"+minute;
- if(second<10) hour = "0"+second;
- var tempo = hour+":"+minute+":"+second;
- document.getElementById("timer").innerHTML=tempo;
- }
- function initTime(){
- setInterval(showTime, 1000);
- }
- </script>
- </head>
- <body onLoad="initTime();">
- <span id="timer">Horas</span>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment