JavaScript 检查日期不是今天或过去。
var c = '10 JUN 2010'; // this is the format of the date coming in.
var temp = new Array();
temp = c.split(' ');
var x = new Date ( temp[1]+" "+temp[0]+", "+temp[2] );
if (x.getTime() > getDate()) {
alertstring = alertstring + '\n\nDEBUG CODE: 1 ' + x + '\n\n';
}
我无法更改传入的格式。
最佳答案
看来你 99% 都做到了。这是修改后的 if 条件:
var c = '10 JUN 2010'; // this is the format of the date coming in.
var temp = new Array();
temp = c.split(' ');
var x = new Date ( temp[1]+" "+temp[0]+", "+temp[2] );
if (x.getTime() > (new Date().getTime())) {
...
}
关于JavaScript 检查日期不是今天或过去,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7421988/