Here’s a function in PHP to validate Unix timestamp:
function isValidTimeStamp($strTimestamp) { return ((string) (int) $strTimestamp === $strTimestamp) && ($strTimestamp <= PHP_INT_MAX) && ($strTimestamp >= ~PHP_INT_MAX); }
Advertisements
Here’s a function in PHP to validate Unix timestamp:
function isValidTimeStamp($strTimestamp) { return ((string) (int) $strTimestamp === $strTimestamp) && ($strTimestamp <= PHP_INT_MAX) && ($strTimestamp >= ~PHP_INT_MAX); }
I think the following would be better, as the input could be an integer as well: (string) $strTimestamp
function isValidTimeStamp($strTimestamp) {
return ((string) (int) $strTimestamp === (string) $strTimestamp)
&& ($strTimestamp = ~PHP_INT_MAX);
}