Arepalli Praveenkumar Arepalli Praveenkumar - 1 year ago 91
Javascript Question

How to set Hours,minutes,seconds to Date which is in GMT

I have Date Object ,I wanted to clear HOUR,MINUTE and SECONDS from My Date.Please help me how to do it in Javascript. Am i doing wrong ?

var date = Date("Fri, 26 Sep 2014 18:30:00 GMT");

Expected result is

Fri, 26 Sep 2014 00:00:00 GMT

How Do I achieve ?

Answer Source

You can use this:

// Like Fri, 26 Sep 2014 18:30:00 GMT
var today = new Date();

var myToday = new Date(today.getFullYear(), today.getMonth(), today.getDate(), 0, 0, 0);

Recreate the Date object with constructor using the actual date.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download