Hello,
we have outOfBox : addMonths, addYears, .. .
is not better so : .. so we can add and substract . like ModifyMonth(createAt, 3) . or ModifyMonth(createAt, -3)
Regards
we have outOfBox : addMonths, addYears, .. .
is not better so : .. so we can add and substract . like ModifyMonth(createAt, 3) . or ModifyMonth(createAt, -3)
Regards
PHP Code:
namespace Espo\Custom\Core\Formula\Functions\DatetimeGroup;
use \Espo\Core\Exceptions\Error;
class ModifyMonth extends \Espo\Core\Formula\Functions\Base
{
public function process(\StdClass $item)
{
if (!property_exists($item, 'value')) {
return true;
}
if (!is_array($item->value)) {
throw new Error();
}
if (count($item->value) < 2) {
throw new Error();
}
$dateValue = $this->evaluate($item->value[0]);
$modifyValue = $this->evaluate($item->value[1]);
$date = new \DateTime($dateValue);
$date->modify( $modifyValue .' month');
return $date->format('Y-m-d');
}
}
Comment