I have this function
//--format ISO8601 date into sections
function formatDate(date){
var a = date.split(/[T]/);
var d = a[0].split("-"); // date
var t = a[1].split(":"); // time
t[2] = t[2].split("-"); // Remove Time zone offset
var formattedDate = new Date(d[0],(d[1]-1),d[2],t[0],t[1],t[2][0]);
//formattedDate.replace(/ *\([^()]*\) */g, "");
return formattedDate;
}
which returns a date that looks like this
Tue Jan 15 2013 11:07:14 GMT-0500 (Eastern Standard Time)
I want to remove the (Eastern Standard Time) part. I tried doing formattedDate.replace, but it won’t work because I believe it isn’t a String.
Any suggestions?
EDIT:
My desired output is
Tue Jan 15 2013 11:07:14 GMT-0500
What you return is a
Dateinstance. When you output it (by logging it etc), it is converted into a string. So what you want is.toString()and then use string functions: