On Fri, Mar 13, 2009 at 12:03 AM, Dave Maharaj :: WidePixels.com
<[email protected]> wrote:
>
> I am trying to use the beforeSave function to create an expiration date 30
> days from creation time.
>
> function beforeSave() {
> if(!empty($this->data['Ticket']['user_id'])) {
> $this->data['Ticket']['expires'] =
> $this->expiresDate($this->data['Ticket']['created']);
> }
> return true;
> }
>
> function expiresDate($dateString) {
> $future = strtotime('+30 days', $dateString);
> return date('Y-m-d', strtotime($future));
> }
>
I was just working on something similar. You have to pass a timestamp
as the 2nd param:
$future = strtotime('+30 days', strtotime($dateString));
So, you could just change the method to:
function expiresDate($dateString) {
return date(
'Y-m-d',
strtotime(
'+30 days',
strtotime($dateString)
)
);
}
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---