我有这种方法可以得到明天的约会对象。
var tomorrow = date.getDate() + "/" + month + "/" + date.getFullYear();
这将返回 2/10/2013 我希望它是 02/10/2013 (单个数字为零)
这是进行日期比较所必需的。
if(02/10/2013==2/10/2013){
dosomething();
}
由于该问题,以上内容不起作用。
最佳答案
你可以通过
var tomorrow = ('0' + date.getDate()).slice(-2) + "/" + ('0' + (date.getMonth()+1)).slice(-2) + "/" + date.getFullYear();
关于javascript datetime 将零添加到单个数字值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19114558/