@JoshDaBosh/

current-time-javascript-part-2

HTML, CSS, JS

No description

fork
loading
Files
  • index.html
  • script.js
  • style.css
index.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width">
    <title>Joshua Justin</title>
    <link href="style.css" rel="stylesheet" type="text/css" />

    <script>

      var popup;

      function date(){
        var x = new Date();
        
        var days = ["Sunday", "Monday", "Tuesday", "Wednedsay", "Thursday", "Friday", "Saturday"]
        
        var day = days[x.getDay()].substring(0, 3);
        var y = parseInt(x.getSeconds())
        if (y<10){
          y = '0'+y
        }
        var z = parseInt(x.getMinutes())
        if (z<10){
          z = '0'+z
        }
        var time = x.getHours() + ':' + z + ':' + y;

        var thing = parseInt(x.getMonth())+1

        var thing2 = parseInt(x.getDate())

        if(thing < 10){
          thing = "0"+thing;
        }
        if(thing2 < 10){
          thing2 = "0"+thing2;
        }

        var msg = x.getFullYear()+"/"+ thing +"/"+ thing2 +" " + day + ", " + time;

        var top=window.screen.availHeight-500,
        left=window.screen.availWidth-600;

        popup = window.open(" ", "uh", "height=500, width=600, top="+top+", left="+left);

        popup.document.write('<html>\n<head>\n</head><body>')
        popup.document.write('Current time: <input type = "text" readonly value="'+msg+'" />');
        popup.document.write('</body></html>')
        
        
      }

    </script>
  </head>
  <body>
    <center>
      <form name="f">
        <input type="button" onclick="date()" value="Show Detail Date Time">
      </form>
    </center>
  </body>
</html>
result
console