Javascript Dates : change time
date, javascript
Solution
var date = new Date();
date.setHours( 0,0,0,0 );
`setHours()` actually has two effects:
- It modifies the object it is applied to
- It returns the new timestamp of that date object
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.
Problem
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