@JoshDaBosh/

date and time js

HTML, CSS, JS

for p1 compsci joshua wang, justin chen

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
  <!DOCTYPE html>
  <html>
    <head>
      <meta charset="utf-8">
      <meta name="viewport" content="width=device-width">
      <title>repl.it</title>
      <link href="style.css" rel="stylesheet" type="text/css" />

      <script>

        function x(){
          var x = new Date();
          var pad = "00000000";
          
          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 time = x.getHours() + ':' + x.getMinutes() + ':' + 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 + "\n" + day + ", " + time;


          alert(msg);

          
        }

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