I have a string and I need to find out whether it is a unix timestamp or not, how can I do that effectively?
I found this thread via Google, but it doesn\'t come up
I came across the same question and created the following solution for my self, where I don't have to mess with regular expressions or messy if-clauses:
/**
* @param string $string
* @return bool
*/
public function isTimestamp($string)
{
try {
new DateTime('@' . $string);
} catch(Exception $e) {
return false;
}
return true;
}