var date = new Date()
Output: "Wed Nov 28 2012 14:55:24 GMT-0500 (Eastern Standard Time)"
Want to get rid of the UT and time to output:
"Wed Nov 28 2012"
var date = new Date()
Output: "Wed Nov 28 2012 14:55:24 GMT-0500 (Eastern Standard Time)"
Want to get rid of the UT and time to output:
"Wed Nov 28 2012"
You may use toDateString()
:
new Date().toDateString(); // "Wed Nov 28 2012"
Use the toDateString
method instead of (implicit) toString
:
> new Date().toDateString()
"Wed, 28 Nov 2012"
However, it is implementation-dependent, so if you really need exactly your format you don't get around
var date = new Date();
var day = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"][date.getDay()];
var mon = ["Jan", "Feb", "Apr", "Mar", "Mai", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"][date.getMonth()];
return day+" "+mon+" "+date.getDate()+" "+date.getFullYear();
Or have a look at one of the many Date libraries and their format
methods.