Wednesday, September 2, 2015

Re: Compare 2 date in cake3



Il giorno mercoledì 2 settembre 2015 12:17:42 UTC+2, Anthony GRASSIOT ha scritto:

And that's normal and make sense because $calendar->start_date and $calendar->end_date are the only fields for which you use setters...



ok, solved ;)
just format date in array data first to process it in patchEntity :

if(isset($this->request->data['start_date']) && trim($this->request->data['start_date']) != '')
{
$calendar_data['start_date'] = implode("-",array_reverse(explode("/", $this->request->data['start_date'])));
}
if(isset($this->request->data['end_date']) && trim($this->request->data['end_date']) != '')
{
$calendar_data['end_date'] = implode("-",array_reverse(explode("/", $this->request->data['end_date'])));
}
 
$calendar = $this->Calendars->patchEntity($calendar, $calendar_data);

--
Like Us on FaceBook https://www.facebook.com/CakePHP
Find us on Twitter http://twitter.com/CakePHP

---
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to cake-php+unsubscribe@googlegroups.com.
To post to this group, send email to cake-php@googlegroups.com.
Visit this group at http://groups.google.com/group/cake-php.
For more options, visit https://groups.google.com/d/optout.

No comments: