-6

I was wondering if I could give the current time a varible and how to do it. HTML. It most likely uses a var statement but I don't know how to actually get the current time.

Paesano2000
  • 313
  • 2
  • 16
Ryan King
  • 1
  • 1

3 Answers3

1
<script>
    var now = new Date(); // actual time
</script>
Sebastian
  • 345
  • 2
  • 8
1

The simplest thing! If you google for 3 seconds you can get tons of articles.

var currentTime = new Date();
Marcos Pérez Gude
  • 21,869
  • 4
  • 38
  • 69
0

Something like this?

var dt = new Date();

var time = dt.getHours()+" : "+dt.getMinutes()

//Append current hours and minutes together. Append dt.getSeconds() to get current time upto the second.

gothical
  • 373
  • 1
  • 7