Pretty sure you just want TimeConstrained:
TimeConstrained
TimeConstrained[ code, limit]
That will return as $Aborted, but you can also return a different failure case with the 3rd argument:
$Aborted
TimeConstrained[Do[i^2, {i, 1000000}], 1, $Failed]