You have always the option to use the afterfind() method...
But I think you need to use it in every model...

There is an exemple in cake book doing exactly this:
http://book.cakephp.org/view/681/afterFind

<http://book.cakephp.org/view/681/afterFind>

function afterFind($results) {
        foreach ($results as $key => $val) {
                if (isset($val['Event']['begindate'])) {
                        $results[$key]['Event']['begindate'] =
$this->dateFormatAfterFind($val['Event']['begindate']);
                }
        }
        return $results;
}

function dateFormatAfterFind($dateString) {
        return date('d-m-Y', strtotime($dateString));
}


I guess you can modify this to make your custom function and put it in your
app/AppModel.php
So it will work for every model you have in your project...

--
Renato de Freitas Freire
[email protected]


On Fri, May 7, 2010 at 9:26 AM, Andrei Mita <[email protected]> wrote:

> I only saw "several" views in your e-mail :)
>
> You can always say NO or explain the situation. Who am I kidding here....
> marketing people.... understanding? :)
>
> You can change the way your database stores dates, but then you might have
> problems in other places like controllers and actions where you do your
> logic.
>
>
> On Fri, May 7, 2010 at 3:08 PM, leberle <[email protected]> wrote:
>
>> Hey Andrei, thanks for your answer!
>>
>> Unfortunately we have A LOT of views (as i wrote), so editing all
>> views and use the time-helper is not really an option :/ ...or the
>> last one.
>>
>> On 6 Mai, 21:29, Andrei Mita <[email protected]> wrote:
>> > You can use the Time helper to format the date anyway you want, I think.
>> >
>> >
>> >
>> > On Thu, May 6, 2010 at 6:33 PM, leberle <[email protected]> wrote:
>> > > Hi,
>> >
>> > > I'm looking for a generic way to re-format date-values i fetched from
>> > > mysql....so, the complete context:
>> >
>> > > We have a complex cake web-app using a mysql db. So, the default date-
>> > > format returned by mysql is yyyy-mm-dd. This was fine for a long time.
>> > > Now our lovely marketing has decided that our sales will increase by
>> > > 200023904906% if we change the date-format in the views to dd.mm.yyyy.
>> > > Unfortunatley we are reading date-values from different models and use
>> > > them in several views...so switching the format by editing the queries
>> > > or re-format the dates in the views would be a very time-expensive
>> > > thing.
>> >
>> > > I thought of a afterfind-callback in the app_model to have at least
>> > > something generic, but i'm not sure if there is a smarter way to solve
>> > > this problem. Can anyone help?
>> >
>> > > Check out the new CakePHP Questions sitehttp://cakeqs.organd help
>> others
>> > > with their CakePHP related questions.
>> >
>> > > 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]<cake-php%[email protected]>
>> <cake-php%[email protected]<cake-php%[email protected]>>For
>> more options, visit this group at
>> > >http://groups.google.com/group/cake-php?hl=en
>> >
>> > Check out the new CakePHP Questions sitehttp://cakeqs.organd help others
>> with their CakePHP related questions.
>> >
>> > 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]<cake-php%[email protected]>For
>> >  more options, visit this group athttp://
>> groups.google.com/group/cake-php?hl=en
>>
>> Check out the new CakePHP Questions site http://cakeqs.org and help
>> others with their CakePHP related questions.
>>
>> 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]<cake-php%[email protected]>For
>>  more options, visit this group at
>> http://groups.google.com/group/cake-php?hl=en
>>
>
>  Check out the new CakePHP Questions site http://cakeqs.org and help
> others with their CakePHP related questions.
>
> 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]<cake-php%[email protected]>For
>  more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en
>

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

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

Reply via email to