Validate if age is over 18 years old

前端 未结 6 2341
情歌与酒
情歌与酒 2020-12-14 12:23

Just wondering, can I do this to validate that a user has entered a date over 18?

//Validate for users over 18 only
function time($then, $min)
{
    $then =          


        
6条回答
  •  陌清茗
    陌清茗 (楼主)
    2020-12-14 12:55

    if( strtotime("1988/03/23") < (time() - (18 * 60 * 60 * 24 * 365))) {
      print "yes";
    } else {
      print "no";
    }
    

    ...not accounting for leaps years however

提交回复
热议问题