Created
March 19, 2013 16:35
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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