Well that is not working for me, I had to make my own function. I'ts easy
but it seems to be something that Cake should do, not me xD

2010/10/1 Miles J <[email protected]>

> I am pretty sure cake "formats" date/time arrays into a timestamp
> before inserting. Thats how table columns within a form field are
> automatically converted to select dropdowns and converted back into a
> timestamp before saving.
>
> On Oct 1, 8:55 am, "j.blotus" <[email protected]> wrote:
> > just put it in your beforeSave function and it will do whatever you
> > need
> >
> > On Oct 1, 11:23 am, Hugo M <[email protected]> wrote:
> >
> > > Ok, but... I don't want a now() date xD, I want a date set by the user
> in a
> > > form, because it's an "expiring date" field, so I don't think I would
> use
> > > created and modified CakePHP fields.
> >
> > > I created my own method for converting form-cakephp-date-input array
> format
> > > to a timestamp format, but I think CakePHP should handle this.
> >
> > > (AppModel.php)
> >
> > >     //Returns a timestamp understable by the database from a form input
> > > array
> > >     public function timestamp($dateTimeArray) {
> > >         return
> > >
> "{$dateTimeArray['year']}-{$dateTimeArray['month']}-{$dateTimeArray['day']}
> > > {$dateTimeArray['hour']}:{$dateTimeArray['min']}:0";
> > >     }
> >
> > > 2010/10/1 j.blotus <[email protected]>
> >
> > > > you can change the field names for created and modified:
> >
> > > > in the model:
> >
> > > >               /**
> > > >         *
> > > >         * @var string tells cake the name of the created field on
> insert
> > > >         */
> > > >        var $createField = 'entered';
> > > >        /**
> > > >         *
> > > >         * @var string tells cake the name of the modified field on
> update
> > > >         */
> > > >        var $updateField = 'modified';
> >
> > > > in the beforeSave() of the model:
> >
> > > >        /**
> > > >         * Before saving set up created and modified so we know when
> record
> > > > was changed
> > > >         *
> > > >         * @return boolean true always
> > > >         */
> > > >        function beforeSave() {
> > > >                // Alternate column automagic timestamping support
> > > >                $nowDate = date('Y-m-d H:i:s');
> > > >                if ($this->updateField) {
> > > >                        $this->set($this->updateField, $nowDate);
> > > >                }
> > > >                if ($this->createField and !$this->exists()) {
> > > >                        $this->set($this->createField, $nowDate);
> > > >                }
> >
> > > >                return true;
> > > >         }
> >
> > > > On Oct 1, 11:01 am, Hugo M <[email protected]> wrote:
> > > > > I'm trying to fill an "expiring date" field, so I can't use the
> created
> > > > and
> > > > > modified/updated Cake automagic fields.
> >
> > > > > 2010/10/1 Jeremy Burns | Class Outfit <[email protected]
> >
> >
> > > > > > What are you trying to achieve the Cake doesn't already do with
> the
> > > > created
> > > > > > and modified fields which already get populated with 'now'?
> >
> > > > > > Jeremy Burns
> > > > > > *Class Outfit*
> > > > > > *
> > > > > > *
> > > > > > [email protected] <[email protected]>
> > > > > >http://www.classoutfit.com
> >
> > > > > > On 1 Oct 2010, at 15:36, Hugo M wrote:
> >
> > > > > > There's a way to save timestamp field without manually joining
> the
> > > > hour,
> > > > > > day, year, etc. fields?
> >
> > > > > > $this->Form->input('timestampfield');
> >
> > > > > > When I do that, in backend I get:
> >
> > > > > >  [timestampfield] => Array
> > > > > >                 (
> > > > > >                     [month] => 10
> > > > > >                     [day] => 01
> > > > > >                     [year] => 2010
> > > > > >                     [hour] => 11
> > > > > >                     [min] => 37
> > > > > >                     [meridian] => am
> > > > > >                 )
> >
> > > > > > And I need to manually construct the timestamp field, is that OK?
> :S
> >
> > > > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp
> > > > 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] om>For more options, visit this
> group
> > > > > > athttp://groups.google.com/group/cake-php?hl=en
> >
> > > > > >  Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp
> > > > > > 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] om>
> > > > <cake-php%[email protected]­om>For more options, visit
> this
> > > > group at
> > > > > >http://groups.google.com/group/cake-php?hl=en
> >
> > > > Check out the new CakePHP Questions sitehttp://cakeqs.organdhelp
> 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] om>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