Do you know an elegant way to change the time in a Date Object in javascript
The strangness is those setters that return Number object
var date = new Date().setHours(0,0,0,0);
date is a Number not a date..
so let’s say I have a date
var date = new Date()
and I want to change time
Thank you
setHours()actually has two effects:So in your case, just create the object and set the time separately afterwards. You can then ignore the return value entirely, if you don’t need it.