PHP: Timestamp validator and converter
-
<?php
-
-
/*
-
* Timestamp validator and converter
-
* {cc} Owen Mundy ~ owenmundy.com
-
*
-
*/
-
function convert_date($string)
-
{
-
// make sure it is a string with a number && > 1992-05-07 && < 2033-05-18
-
if ( ctype_digit($string) && $string >= 800000000 && $string <= 1999999999 )
-
{
-
// if so convert it to a human-readable date
-
$d = date(‘Y-m-d H:i:s’, $string);
-
return $d;
-
}
-
else
-
{
-
return false;
-
}
-
}
-
-
print convert_date("1613199869");
-
-
?>
Thanks
Tags: code, PHP
This entry was posted
on Monday, May 3rd, 2010 at 9:31 am and is filed under sketches.
You can follow any responses to this entry through the RSS 2.0 feed.
Both comments and pings are currently closed.