I want to validate dates…these dates are picked from the users from a calendar.
After a search I made here and elsewhere…this method might help.
This dates are coming from the client as strings…for example: “2015-02-18 15:00:00”
VALIDATE_INT is useless here cause it outputs FALSE when accepting input such as this above.
I cannot think other validating mechanism apart from the method I list here.
$startdate = DateTime::createFromFormat('Y-m-d H:i:s', $content['start']);
$date_errors = DateTime::getLastErrors();
if ($date_errors['warning_count'] + $date_errors['error_count'] > 0)
{
echo json_encode('problem with the dates.');}
$content['start'] //this is just a the variable that holds the date string