PHP: Timestamp validator and converter

  1. <?php
  2.  
  3. /*
  4.  *  Timestamp validator and converter
  5.  *  {cc} Owen Mundy ~ owenmundy.com
  6.  *
  7.  */  
  8. function convert_date($string)
  9. {
  10.     // make sure it is a string with a number && > 1992-05-07 && < 2033-05-18
  11.     if ( ctype_digit($string) && $string >= 800000000 && $string <= 1999999999 )
  12.     {
  13.         // if so convert it to a human-readable date
  14.         $d = date(‘Y-m-d H:i:s’, $string);
  15.         return $d;
  16.     }
  17.     else
  18.     {
  19.         return false;  
  20.     }
  21. }
  22.  
  23. print convert_date("1613199869");
  24.  
  25. ?>

Thanks