var currenttime = 'March 21, 2019 20:43:46' var serverdate=new Date(currenttime); function padlength(what){ var output=(what.toString().length==1)? "0"+what : what return output } function displaytime(){ serverdate.setSeconds(serverdate.getSeconds()+1) var timestring=padlength(serverdate.getHours())+":"+padlength(serverdate.getMinutes())+":"+padlength(serverdate.getSeconds()); $(".jclock").text(timestring); }