i found a solution : in my CalendarController i did : function edit { [...] if (empty($this->data)) { $this->data = $this->Calendar->read(null, $id); } #as CakePHP does not "understand" a unix timestamp i force the type to integer thus Cake will see #it correctly to transform the timestamp in 3 arrays for the date; $this->data['Calendar']['date'] = (integer) $this->data['Calendar'] ['date']; }
On 8 juin, 18:47, "b logica" <[EMAIL PROTECTED]> wrote: > I think that you might be mixing up timestamps and date strings. > mktime() returns a UNIX timestamp, which is an integer, being the > number of seconds elapsed since Ken Thompson & Dennis Ritchie say so. > While you may have a timestamp column in your DB, it's probably > serving the data up formatted as a date string, much like a DATETIME > column. > > "2008-06-08 12:25:32" (or "20080608122532") vs "1212942514" > > strtotime() can use the former but the latter needs to be converted > into some kind of date string first. > > In any case, I can't quite understand what it is you need to do. > Perhaps all of this is unnecessary. > > On Sun, Jun 8, 2008 at 6:57 AM, foxmask <[EMAIL PROTECTED]> wrote: > > > Hello, > > my database table contain a date in integer to store a timestamp. > > > When , in my form i write this in my form : > > <?php echo $form- > >>input('date',array('type'=>'date','label'=>false,'dateFormat'=>'DMY'));? > > > i can get the data like this to store them in my date column: > > > $m = (integer) $this->data['Calendar']['date']['month']; > > $d = (integer) $this->data['Calendar']['date']['day']; > > $y = (integer) $this->data['Calendar']['date']['year']; > > if ( !checkdate ($m,$d,$y) ) { > > $common_warning = __('the date is not a valid',true); > > } > > else > > $this->data['Calendar']['date'] = > > mktime(0,0,0,$this->data['Calendar'] > > ['date']['month'], > > > > $this->data['Calendar']['date']['day'], > > > > $this->data['Calendar']['date']['year']); > > > My problem is : when i edit the data from my form, > > instead of displaying 08 june 2008 > > i read :1 january 2028 ! > > > this is the fault of the strtotime function used in the function year > > of the form helper... > > > My Question is : how can i give the Cake the correct format of my date > > before displaying the edit form .? > > > i have tried $this->data['Calendar']['date'] = date("Y-m-d",$this- > >>data['Calendar']['date']) ; > > but that does not do the trick. > > > Regards. --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cake-php?hl=en -~----------~----~----~----~------~----~------~--~---