title: Parsing dates with d3.js v.4
body: <p>I'm trying to learn how to code with the d3.js by working on my first d3 <a href="https://www.freecodecamp.com/challenges/visualize-data-with-a-bar-chart" rel="noreferrer">mini project</a> based on the Free Code Camp curriculum. I am trying to make a simple bar graph with this <a href="https://raw.githubusercontent.com/FreeCodeCamp/ProjectReferenceData/master/GDP-data.json" rel="noreferrer">json file</a>. I got stuck trying to format the dates in the file. I've tried looking at the <a href="https://github.com/d3/d3-time-format/blob/master/README.md#timeFormat" rel="noreferrer">d3.js API</a> and I am still lost. I would be very grateful for any advice that comes my way. Here is my code</p>
  
  <pre><code>    // set the dimensions and margins of the graph
  var margin = {top: 20, right: 20, bottom: 30, left: 40},
      width = 960 - margin.left - margin.right,
      height = 500 - margin.top - margin.bottom;
  
  //then make a function to parse the time
  var parseDate = d3.timeFormat("%Y-%m-%d");
  
  // set the ranges
  var x = d3.scaleBand().rangeRound([0, width]).padding(0.1);
  var y = d3.scaleLinear().range([height, 0],0.5);
  
  // append the svg object to the body of the page
  // append a 'group' element to 'svg'
  // moves the 'group' element to the top left margin
  var svg = d3.select("body").append("svg")
      .attr("width", width + margin.left + margin.right)
      .attr("height", height + margin.top + margin.bottom)
    .append("g")
      .attr("transform", 
            "translate(" + margin.left + "," + margin.top + ")");
  
  
  //setup axis
  
  
  // get the data
  d3.json("https://raw.githubusercontent.com/FreeCodeCamp/ProjectReferenceData/master/GDP-data.json").get(function(error,dataset){
    var d =dataset.data;
    d.forEach(function(datum, i) {
          d[0]=parseDate(datum[0]);
           //console.log(datum[1]);
      });
    //console.log(d[3][0]);
  
  });
  </code></pre>