This is dependant on what version of MySQL you are running.
I will assume you are running 4.1.x or higher
In MySQL 4.1.x, TIMESTAMP is returned as a string in the format 'YYYY-MM-DD HH:MM:SS'
to make sure that an entry is a mysql timestamp:
<?
// we'll just say that $timestamp holds the value pulled from MySQL
$timestamp = preg_split("/[\s-:]+/", $timestamp);
// this will create an array, seperating year, month, day, hour, minute, and second
// now all we need is an if statament to make sure that all elements are correct
if (
sizeof($timestamp) == 6
&&
is_numeric($timestamp[0])
&&
strlen($timestamp[0] == 4
&&
is_numeric($timestamp[1])
&&
strlen($timestamp[0] == 2
&&
is_numeric($timestamp[2])
&&
strlen($timestamp[0] == 2
&&
is_numeric($timestamp[3])
&&
strlen($timestamp[0] == 2
&&
is_numeric($timestamp[4])
&&
strlen($timestamp[0] == 2
&&
is_numeric($timestamp[5])
&&
strlen($timestamp[0] == 2
)
{
echo "This is a MySQL timestamp!<br>\n";
}
else
{
echo "This is not a MySQL TimeStamp.<br>\n";
}
?>