如何通过Java脚本进行露营 [英] how to campair date by java script

查看:134
本文介绍了如何通过Java脚本进行露营的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

var CurrentDate = CurrentDate();
此行消息出现对象预期的
请帮帮我.

var CurrentDate = CurrentDate();
this line message appear object expected
Please help me.

function Check_ToDate(obj) {
           var txtPrevDate = gebi("ctl00_cph1_txtPrevDate");
           gebi('divDate').style.display = "none";
           //obj.className = "unwatermarked";
           //gebi('row').style.display = "block";
           if (gebi(obj).value != "Please type here...") {
               var arrPreDate = gebi(obj).value.split(" ");
               var Date = arrPreDate[1] + " " + arrPreDate[0] + " " + arrPreDate[2];

               var CurrentDate = CurrentDate();
               if (Date.parse(Date) > (Date.parse(CurrentDate))) {
                   gebi('divDate').innerHTML = "<img src='images/error.gif' alt='' />Previous date must not be greater than current date...";
                   gebi('divDate').style.display = "block";
                   obj.className = "unwatermarked_Error";
                   return false;
               }

           }
           return true;
       }

推荐答案

尝试var currentDate = new Date();
Try var currentDate = new Date();


解决方案1正确,您可以调用具有新功能的Date函数,并且Javascript中没有CurrentDate函数来获取当前日期

因此要获取当前日期,您必须使用
Solution 1 is right that you have call Date function with a new and there is no CurrentDate function in Javascript for getting current date

so for getting current date you have to use
var CurrentDate = new Date();



现在,为了比较两个单独的日期,您可以直接比较两个日期对象,如下面的示例所示



Now for comparing two separate date you can directly compare two date objects just as shown in below example

var x=new Date();
x.setFullYear(2013,03,02);
var today = new Date();
if (x>today)
{
  alert("Today is before 2nd March 2013");
}
else
{
  alert("Today is after 2nd March 2013");
}


这篇关于如何通过Java脚本进行露营的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆