getmonth()不是解析日期的函数错误 [英] getmonth() is not a function error parsing date
本文介绍了getmonth()不是解析日期的函数错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个带有 production_date
的对象,我试图提取年份和月份,但我一直在 getMonth()
和 getYear()
不是函数错误...
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
}
推荐答案
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)
这篇关于getmonth()不是解析日期的函数错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文