日期验证不是今天 [英] date validation not to be today

查看:90
本文介绍了日期验证不是今天的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要验证2日期,不要相同。如果相同,则返回false.Code在PHP中。它始终将o / p作为false。

I need to validate 2 date that never should be same.If same it will return false.Code is in PHP.It is always giving o/p as false.

function BeforeAdd($values, $message, $inline, $pageObject)
{
$d1 =$values['DATE'];     //date 1 in dd/mm/yyyy format
$d2 =$values['DATE OF LEAVE'];   //date 2 in dd/mm/yyyy format
if($d1 <> $d2)
{
return true;  
}
echo '<script language="javascript">';
echo 'alert(Application date and leave date should be different.)';
echo '</script>';
return false;  
}

我有另一个代码正在部分工作。

I have another code that is working partially.

function BeforeAdd($values, $message, $inline, $pageObject)
{
$d1 =$values['DATE'];     //date 1 in dd/mm/yyyy format
$d2 =now();  
if($d1>$d2)
{
return true;  
}
echo '<script language="javascript">';
echo 'alert(Application date and leave date should be different.)';
echo '</script>';
return false;  
}

当我使用这个if($ d1 <$ $ d2)允许所有的东西。

When i am using this if($d1<>$d2) it is allowing everything.

推荐答案

任何人都可以建议我一个代码返回false id日期是今天其他true格式

Any one can suggest me a code to return false id date is today else true in the format

function BeforeAdd($values, $message, $inline, $pageObject)
{
    $d1 = $values['DATE'];     //date 1 in dd/mm/yyyy format
    $d2 = now();  

    if($d1>$d2)
    {
        return true;  
    }

    echo '<script language="javascript">';
    echo 'alert(Application date and leave date should be different.)';
    echo '</script>';

    return false;  
}

这篇关于日期验证不是今天的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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