get start of day javascript 1

get start of day javascript

var start = new Date();
start.setHours(0,0,0,0);

var end = new Date();
end.setHours(23,59,59,999);

alert( start.toUTCString() + ':' + end.toUTCString() );

Here is what the above code is Doing:
1. Create a new Date object, and set the time to midnight.
2. Create a new Date object, and set the time to 11:59:59 PM.
3. Alert the two dates.

The result is:

Wed, 01 Jan 2014 00:00:00 GMT:Wed, 01 Jan 2014 23:59:59 GMT

Similar Posts