As I mentioned in the topic below I am just learning Javascript. I have searched high and low for a solution to this problem.
I need a method for getting the current time, adding some seconds onto that time, then formatting that time in javascript as readable time.
The code below is part of a larger function which gets looped by set interval.
My hope is i can get this code to display: HH:MM:SS as the current server time + the time in seconds I add to it. Not the amount of hours, mins and seconds since a time in the past. this currently shows the real time if I remove the +travelTime from the variables but I have tried a lot of combinations to get this to work as well as it does so far.
Thanks in advance for any help you can offer!
Here is my code so far:
Code: Select all
var travelTime = (distance * timePerUnit) / travelSpeed;
var timeH = new Date().getHours()+travelTime;
var timeM = new Date().getMinutes()+travelTime;
var timeS = new Date().getSeconds()+travelTime;
//var arriveAt = (time + travelTime);
var arriveAt = timeH + ":" + timeM + ":" + timeS;
document.getElementById('arrivalTime').value = arriveAt;