Reputation:
I am getting Date in this format (Fri May 13 2011 19:59:09 GMT 0530 (India Standard Time) )
Please tell me how can i use Javascript split function , so that i can get only May 13 2011 ??
Upvotes: 2
Views: 326
Reputation: 104760
You can make arrays of the string and manipulate the array members back to a string, but it is simpler to just cut the existing string at the space before the hours.
var D='Fri May 13 2011 19:59:09 GMT 0530 (India Standard Time)';
alert(D.substring(0, D.search(/\s+\d{2}\:/))
/* returned value: (String)
Fri May 13 2011
*/
Upvotes: 0
Reputation: 14039
You can use Regular expressions:
For this: /[\s][A-Za-z0-9]+[\s][0-9]+/
Upvotes: 0
Reputation: 14550
var date_split = date_string.split(" ");
var new_date_string = date_split[1]+" "+date_split[2]+" "+date_split[3];
Upvotes: 0