expiresDate 30 date in the future

3 posts by 2 authors in: Forums > CMS Builder
Last Post: March 29, 2020   (RSS)

By kitsguru - March 28, 2020

I am trying to set the expires date 30 days into the future from now using the membership signup form.

      $colsToValues['createdDate=']     = 'NOW()';
      $colsToValues['updatedDate=']     = 'NOW()';
      $colsToValues['createdByUserNum'] = 0;
      $colsToValues['updatedByUserNum'] = 0;
      $colsToValues['disabled'] = 0;
      $colsToValues['expiresDate'] = '(NOW() + INTERVAL 30 DAY)' ;

The problem I am having is that the expiresDate is not set. In examining the insert statement, the value is quoted which is not a valid date.

NSERT INTO `cmsb_accounts` SET
`createdDate` = NOW(),
`updatedDate` = NOW(),
`createdByUserNum` = '0',
`updatedByUserNum` = '0',
`disabled` = '0',
`expiresDate` = '(NOW() + INTERVAL 30 DAY)'

If the quotes are not present, then the expiresDate is correct.

What is the best way to set the expiresDate using some interval.

------------



Jeff Shields

By kitsguru - March 28, 2020

Found the solution

$expiresDate = new DateTime();
$expiresDate->add(new DateInterval('P30D'));
$colsToValues['expiresDate'] = $expiresDate->format('Y-m-d') ;
------------



Jeff Shields