Uploader

An all around general purpose file uploader for CakePHP. Packaged as a stand alone plugin with file validation, file scanning and support for a wide range of basic mime types.

Within Timeframe

Checks to see if a timestamp was within a certain timeframe/daterange.

Function: withinTimeframe()
Category: PHP
Views: 1,654
Permalink - Tinylink

/**
 * Checks to see if a timestamp was within a certain timeframe/daterange
 * @param int $check
 * @param int $start
 * @param int $finish
 * @return boolean
 */
function withinTimeframe($check, $start, $finish = '') {
	if (!is_int($check))	$check = strtotime($check);
	if (!is_int($start))	$start = strtotime($start);
 
	if (empty($finish)) {
		$finish = time();
	} else {
		if (!is_int($finish)) $finish = strtotime($finish);
	}
 
	if ($check >= $start && $check <= $finish) {
		return true;
	}
 
	return false;
}

Return to Snippets