Menu
Index > Helpers

todoDueDate

todoDueDate($data, $options = array())

Description:
Returns timestamp (default) value of the Todo(Value) due date. You can pass a PHP date() format if you wish within the options array as 'format'.

Options:
(array) $data - the TodoValue.
(array) $options - array('format' => null).

Example:
//
$todoDueDate = $this->Deals->todoDueDate($data);
//
echo 'This Todo is due on ' . date('Y/m/d', $todoDueDate) . '.';

/**
 * 
 *
 * 
 * 
 * 
 */
	public function todoDueDate($data, $options = array()) {
		//
		if (!isset($data['due_date']) && !isset($data['TodoValue']['due_date'])) {
			//
			return	array(date(MYSQL_DATE_FORMAT));
		}
		//
		$return		= isset($data['due_date'])
				? strtotime($data['due_date'])
				: strtotime($data['TodoValue']['due_date']);
		//
		$defaults	= array(
					'format'	=> null
					,
				);
		//
		$options	= am($defaults, $options);
		//
		return		is_null($options['format'])
				? $return
				: date($options['format'], $return);
	}