Ouch, ok.

My *actual* problem is specific to time however: [1]:[02] [AM] becomings -
[1]:[2] in $this->data. Therefore, becoming "1:2am" in my string and causing
me strtotime to fail.

OK, I'll just use my own fields. I just thought there was a simpler method.
Just figured if it's there, I should be using it.

ThanX all.
--
Baz L
Web Development 2.0
http://WebDevelopment2.com/

On Dec 5, 2007 8:41 AM, Adam Royle <[EMAIL PROTECTED]> wrote:

>
> With AD's technique (which looks kinda cool), you would still need to
> write a custom method to handle the data conversion from your date
> input to an sql datetime.
>
> All depends on your form I guess. Since I'm in Australia, I want to
> convert my form fields from
>
> dd/mm/yyyy (aus format) to yyyy-mm-dd (sql format)
>
> and my time from "4:15pm" to 16:15:00
>
> So I have a function to convert the date format - a simple regex:
>
> function convertToSQLDate($date){
>        $date = preg_replace('/^(\d{1,2})\/(\d{1,2})\/(\d{2,4})$/','$3-$2-
> $1', $date);
>        $date = date('Y-m-d',strtotime($date));
>        return $date;
> }
>
>
> And then I create a new string with the sql date I converted above,
> append the time string and send to strtotime...
>
> // so equivalent to doing something like this
> echo date('Y-m-d H:i:s',strtotime('2007-12-05 4pm'));
>
> And voila... your new sql date string is ready :)
>
> Sorry if that's a bit confusing, it's almost 1am here.
>
> Cheers,
> Adam
>
> On Dec 5, 11:48 pm, Baz <[EMAIL PROTECTED]> wrote:
> > Sorry AD, you've totally lost me.
> > --
> > Baz L
> > Web Development 2.0: Web Design, CakePHP,
> Javascripthttp://www.WebDevelopment2.com/
> >
> > On Dec 5, 2007 5:09 AM, AD7six <[EMAIL PROTECTED]> wrote:
> >
> >
> >
> >
> >
> >
> >
> > > On Dec 5, 8:57 am, Baz <[EMAIL PROTECTED]> wrote:
> > > > OK,
> >
> > > > I've banged my head against the wall a million times. This is my
> > > problem:
> >
> > > > I got date and time fields which I need. They are not associated
> with
> > > the
> > > > model or database.
> >
> > > > I call them like so:
> >
> > > >         echo $form->input('from', array('label' => 'From', 'type' =>
> > > 'date',
> > > > 'div' => 'date'));
> > > >         echo $form->input('to', array('label' => 'To', 'type' =>
> 'date',
> > > > 'div' => 'date'));
> > > >         echo $form->input('time', array('label' => 'Time', 'type' =>
> > > 'time',
> > > > 'div' => 'date'));
> >
> > > > However, cleanUpFields doesn't work it's magic like if those fields
> were
> > > in
> > > > the database.
> >
> > > > Any ideas?
> > > > Is there a way to force the model to consider those fields as its
> own?
> >
> > > As things move quite fast, it depends on your cake revision. As of
> > > right now override the schema method, call the parent and then add an
> > > entry for your virtual field.
> >
> > >https://trac.cakephp.org/browser/branches/1.2.x.x/cake/libs/model/mod.
> ..
> >
> > > Although it doesn't make a lot of sense to override schema for a model
> > > that /does/ have a table. you'd normally do so only for a model with
> > > no table, such as the model for validation a contact message, so that
> > > forms work etc.
> >
> > > hth,
> >
> > > AD
> >
>

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Cake 
PHP" group.
To post to this group, send email to cake-php@googlegroups.com
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