//if anything else than digits inside the string then your string is no timestamp
//in which case maybe try to get the timestamp with strtotime
if(preg_match('/[^\d]/', $str)) {
$str = strtotime($str);
if (false === $str) {
//conversion failed - invalid time - invalid row
return;
}
}