_______________________________________________________________________________
该问题已经结贴 ,得分记录:  zairwolfc (100)

解决方案 »

  1.   

    if (preg_match("/2004-(/d){2}-(/d){2}/mU",$string))
      

  2.   

    bool checkdate ( int month, int day, int year)
      

  3.   

    我用的是$dateList = explode("-", $textfield11);
    if(!checkDate($dateList[1], $dateList[0], $dateList[2])) 
               return
    问题是checkdate函数返回要是整型,而我的是字符串,所以无论格式是否是那样,都错误。
    请问怎么解决?
      

  4.   

    比如:2004-08-23,意思就是我先用explode分割成三段,然后用checkdate判断三段的值,我这样用以后就是无论你是输的2004-08-23还是乱输的字符,都不成功。
      

  5.   

    int checkdate(int month, int day, int year);
    参数依次为:月、日、年
    而你的格式为2004-**-**
    $dateList = explode("-", $textfield11);
    后依次为
    $dateList[0] 年
    $dateList[1] 月
    $dateList[2] 日if(!checkDate($dateList[1], $dateList[0], $dateList[2])) 当然是错了

    if(!checkDate($dateList[1], $dateList[2], $dateList[0])) 才行这样写要好一点
    if($textfield11 != date("Y-m-d",strtotime($textfield11)))
      

  6.   

    直接强制转换成这个格式吧,date("Y-m-d", $textfield11);
      

  7.   

    你的$textfield11根本无值吧?