Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <!--
- /////////////////////////////////////////////////////////////////////////////
- /////////////////////////////////////////////////////////////////////////////
- ///////
- /////// Author : EAKKASIT TUNSAKOOL
- ///////
- /////// ref : http://www.plus2net.com/javascript_tutorial/clock.php
- ///////
- /////////////////////////////////////////////////////////////////////////////
- -->
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <meta charset="UTF-8">
- <title>time</title>
- </head>
- <body>
- <script type="text/javascript">
- function updateTime(){
- var currentTime = new Date()
- var hours = currentTime.getHours()
- var minutes = currentTime.getMinutes()
- var seconds = currentTime.getSeconds()
- if (seconds<=9){
- seconds="0"+seconds
- }
- if (minutes < 10){
- minutes = "0" + minutes
- }
- var t_str = hours + ":" + minutes + " "+":"+seconds;
- if(hours > 11){
- t_str += "PM";
- } else {
- t_str += "AM";
- }
- document.getElementById('time_span').innerHTML = t_str;
- }
- setInterval(updateTime, 1000);
- </script>
- <div id="time_span">time</div>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement