AnsweredAssumed Answered

Date saved in Logic Hook switches day and month

Question asked by lsackett on Jan 11, 2016
Latest reply on Jan 12, 2016 by lsackett

In a logic hook, I'm trying to take the value of a custom date field (stored in $quote->date_support_start_c), add 1 year to it in PHP, and save that in a new date field ($bean->date_support_starts). Unfortunately, it is switching the month and day values of the new +1 year date.

 

So in this example, if my starting date was 4/1/16 and the +1 year should be 4/1/17, the result that is saved is 1/4/17. And in cases where the day is above 12, it returns NULL because it cannot switch that day value higher than 12 to a month.

The code should be fairly straight forward and works in local PHP testing:

 

$bean->date_support_starts = date('Y-m-d', strtotime('+1 year', strtotime($quote->date_support_start_c)) );

 

It must be something to do with date preferences or the way dates are stored in Sugar. Can anyone point me in the right direction?

This is in On-Demand 7.5.

Outcomes