Skip to content

Instantly share code, notes, and snippets.

@ThamaraHessel
Created April 9, 2013 17:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ThamaraHessel/5347874 to your computer and use it in GitHub Desktop.
Save ThamaraHessel/5347874 to your computer and use it in GitHub Desktop.
Dúvida do Giovani Silveira na comunidade PHPBrasil no G+.
<?php
//verificação 1
public function setNascimento($data)
{
if(date("Y-m-d", strtotime($data)) != $data){
throw new \InvalidArgumentException("Is not a valid date.");
}
}
//verificação 2
public function setNascimento($data)
{
$date = explode("-", $data);
if(!checkdate($date[1],$date[2],$date[0])){
throw new \InvalidArgumentException("Is not a valid date.");
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment