Reputation: 1303
I am new to Java scripting and trying the following code
//get hours to be added
var r=document.getElementById("select").value;
//value of r can be 5 or 2.5 or so..
var dt=new Date();
var time=dt.getHours();
var time2=dt.setHours(1);
alert(time2);
But I get some long values like this 1398284822090 Isn't there a better way to add hours and than convert it back to standard format? Any documentation for further details will also be helpful. Thanks..
Upvotes: 0
Views: 70
Reputation: 128791
The long value is a timestamp. Calling setHours
actually changes the dt
date, so you can simply:
dt.setHours(1);
alert(dt);
Upvotes: 1