Wednesday, June 5, 2024
 Popular · Latest · Hot · Upcoming
83
rated 0 times [  86] [ 3]  / answers: 1 / hits: 47392  / 8 Years ago, tue, november 22, 2016, 12:00:00

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
}

More From » javascript

 Answers
29
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)


[#59958] Monday, November 21, 2016, 8 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
mackenzihannal

Total Points: 548
Total Questions: 96
Total Answers: 96

Location: Lithuania
Member since Fri, Sep 4, 2020
4 Years ago
;