Skip to content

Instantly share code, notes, and snippets.

@toshimaru
Created October 31, 2012 08:44
Show Gist options
  • Select an option

  • Save toshimaru/3985903 to your computer and use it in GitHub Desktop.

Select an option

Save toshimaru/3985903 to your computer and use it in GitHub Desktop.
check 8-digits-date
<?php
/**
* check 8-digits-date is correct
*
* @param string $date
* @return boolean
*/
protected function checkDate($date)
{
$len = strlen($date);
$intdate = intval($date);
if ($len === 8 && $intdate !== 0) {
$d = str_split($date, 2);
$year = $d[0] . $d[1];
$month = $d[2];
$day = $d[3];
if (checkdate($month, $day, $year)) {
return true;
} else {
return false;
}
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment