user2061886 user2061886 - 14 days ago 8
Javascript Question

getmonth() is not a function error parsing date

I have an object with a

production_date
which I'm trying to extract year and month but I keep getting
getMonth()
and
getYear()
is not a function error...

function(d) {
var dt = d.production_date
var dtm = dt.getMonth();
var dty = dt.getYear();
return dtm + "/" + dty
}

Answer
function(d) { 
          var dt = new Date(d.production_date);
          var dtm = dt.getMonth();
          var dty = dt.getFullYear();
          return dtm + "/" + dty 
       }

If it's passed over network, you'll only have a number (timestamp)