Skip to content

Instantly share code, notes, and snippets.

@cherihung
Created March 19, 2013 16:35
Show Gist options
  • Save cherihung/5197687 to your computer and use it in GitHub Desktop.
Save cherihung/5197687 to your computer and use it in GitHub Desktop.
parse date string YYYY-MM-DD to a date object array; use to plot with amCharts
function parseDate(dateString) {
//first slice off hours and minutes; only take YYYY-MM-DD
var strip_date = dateString.slice(0,10);
var dateArray = strip_date.split("-");
// create instance year, month and day as parameters
var date = new Date(Number(dateArray[0]), Number(dateArray[1]) - 1, Number(dateArray[2]));
return date;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment