On Fri, Mar 13, 2009 at 12:03 AM, Dave Maharaj :: WidePixels.com
<d...@widepixels.com> 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 cake-php@googlegroups.com
To unsubscribe from this group, send email to 
cake-php+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to