/** * Simply takes an incoming UTC timestamp or DateTime object and does calculations on it based on the incoming parameters and returns the new timestamp or DateTime. * @param int | DateTime $DateTime_or_timestamp DateTime object or Unix timestamp * @param string $period a value to indicate what interval is being used in the calculation. The options are 'years', 'months', 'days', 'hours', 'minutes', 'seconds'. Defaults to years. * @param integer $value What you want to increment the date by * @param string $operand What operand you wish to use for the calculation * @return mixed string|DateTime return whatever type came in. */ public static function calc_date($DateTime_or_timestamp, $period = 'years', $value = 1, $operand = '+') { if ($DateTime_or_timestamp instanceof DateTime) { return EEH_DTT_Helper::_modify_datetime_object($DateTime_or_timestamp, $period, $value, $operand); } else { if (preg_match(EE_Datetime_Field::unix_timestamp_regex, $DateTime_or_timestamp)) { return EEH_DTT_Helper::_modify_timestamp($DateTime_or_timestamp, $period, $value, $operand); } else { //error return $DateTime_or_timestamp; } } }