In javascript, how can I get three different substrings for the date, month, and year from the following string: "12/15/2009" ?
8 Answers
If you want to do any more complex date manipulation, you can also convert the string to a JavaScript Date object like this:
var date = new Date("12/15/2009");
alert(date.getFullYear());
alert(date.getMonth() + 1);
alert(date.getDate());
var newYear = new Date("1/1/2010");
alert((new Date(newYear - date)).getDate() + " days till the new year");