0

I want to get the time from the server and update it every second. I used the setinterval function but it work only one time.

var gettime = function(){
var newDate= new Date("<?= date('Y/m/d H:i:s'); ?>"); 
var seconds=newDategetSeconds();
$("#sec").html(seconds);
}
setInterval(gettime,1000);

and to show it

<div id="sec"><div>

but this works the time is updated every second if i use the javascript code var newDate= new Date() instead of the php code but gives the client time

var newDate= new Date("<?= date('Y/m/d H:i:s'); ?>")
Dababi
  • 185
  • 2
  • 17

0 Answers0