79159091

Date: 2024-11-05 12:28:57
Score: 1
Natty:
Report link
$date_string = "2024-11-05";
if(isDate($date_string))echo "It is a valid date";
else echo "Not a valid date";

function isDate($string){// Specify the expected date format
    $date = DateTime::createFromFormat('Y-m-d', $string); 
    return $date && $date->format('Y-m-d') === $string;
}
Reasons:
  • Low length (0.5):
  • Has code block (-0.5):
  • Low reputation (1):
Posted by: La-Technor Computer Solutions