Accepted answer

Try creating a new Date object before the tick for the x-axis gets passed to the formatter:

.tickFormat(function(d) { return d3.time.format('%b %d')(new Date(d)); })

See the documentation for d3.time.format to see how you can customize the formatting string.


Adding on to seliopou's answer, to correctly align the dates with the x-axis, try this:

      .tickFormat(function(d) {
          return d3.time.format('%d-%m-%y')(new Date(d))

  chart.xScale(d3.time.scale()); //fixes misalignment of timescale with line graph

Related Query

More Query from same tag