I get a date that comes in GMT format, Fri, 18 Oct 2013 11:38:23 GMT. The problem is that time will ruin the schedule I use.
How can I delete everything except the actual date?
Like this:
var dateString='Mon Jan 12 00:00:00 GMT 2015'; dateString=new Date(dateString).toUTCString(); dateString=dateString.split(' ').slice(0, 4).join(' ') console.log(dateString);
If you want to use Date rather than String, you can do this:
var d=new Date(); //your date object console.log(new Date(d.setHours(0,0,0,0)));
-PS, you do not need a new Date object, this is just an example if you want to register it on the console.
http://www.w3schools.com/jsref/jsref_sethours.asp
Just slice it substring :
substring
var str = 'Fri, 18 Oct 2013 11:38:23 GMT'; str = str.substring(0,tomorrow.toLocaleString().indexOf(':')-3);
In this case, you can simply manipulate your string without using a Date object.
Date
var dateTime = 'Fri, 18 Oct 2013 11:38:23 GMT', date = dateTime.split(' ', 4).join(' '); document.body.appendChild(document.createTextNode(date));
I am using this workaround:
// d being your current date with wrong times new Date(d.getFullYear(), d.getMonth(), d.getDate())