Tuesday, May 20, 2014

Re: 3.0 - Saving data using Form with HasOne relationship

That means you have your php and the cakephp database connection configured to use UTC. That is a good thing though, it is better to manage dates in UTC and display them in the local user timezone.

You would normally do, for example:

echo $myEntity->created->nice('Europe/Paris');

On Tuesday, May 20, 2014 7:32:45 PM UTC+2, Bayezid Alam wrote:
When i save a record, the date and time are saving in database 6 hrs back from my local time ( My time is GMT+6). In that sense i called it GMT.

Example: I saved a data at 5/20/14, 11:24 PM (My Local Time, GMT+6) but The record is saving in DB at 5/20/14, 5:24 PM ( which is GMT).

Hope it clarify the things & sorry for the inconvenience.

Thanks
Bayezid



On Tue, May 20, 2014 at 1:48 AM, José Lorenzo <jose.zap@gmail.com> wrote:
what do you mean it is working as gmt?


On Monday, May 19, 2014 7:55:10 PM UTC+2, Bayezid Alam wrote:
Thanks Jose, its working as GMT but format() function is not working here


On Mon, May 19, 2014 at 9:28 PM, Md Bayezid Alam <bayezidece@gmail.com> wrote:
I added Timestamp behavior at ArticlesTable

public function initialize(array $config) {
        $this->addBehavior('Timestamp');
    }

but same fatal error is showing

Error: Call to a member function format() on a non-object
File /var/www/html/test3/App/Template/Profiles/index.ctp
Line: 22 ( <td><?= h($profile->created->format(DATE_RFC850)) ?></td> )


Tried both format() and removing format().

Without format() method, it is saving date as NULL.



On Mon, May 19, 2014 at 7:46 PM, Md Bayezid Alam <bayezidece@gmail.com> wrote:
Nope, i did not.




On Mon, May 19, 2014 at 7:32 PM, José Lorenzo <jose.zap@gmail.com> wrote:
Did you add the Timestamp behavior to your Profiles table?


On Monday, May 19, 2014 3:17:39 PM UTC+2, Bayezid Alam wrote:
Thanks a lot, i changed from username to user_id and its working perfectly

but the second one is not working

here is my table structure

CREATE TABLE IF NOT EXISTS `profiles` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `name` varchar(40) NOT NULL,
  `address` varchar(70) NOT NULL,
  `email` varchar(30) NOT NULL,
  `mobile` varchar(20) NOT NULL,
  `user_id` int(11) NOT NULL,
  `created` datetime DEFAULT NULL,
  `modified` datetime NOT NULL,
  PRIMARY KEY (`id`)
) ENGINE=InnoDB  DEFAULT CHARSET=utf8 AUTO_INCREMENT=16 ;

Below error is showing:

Error: Call to a member function format() on a non-object
File /var/www/html/test3/App/Template/Profiles/index.ctp
Line: 22 ( <td><?= h($profile->created->format(DATE_RFC850)) ?></td> )

After removing Format(Date_RFC850)), the data is saving but created field is entered as NULL.

Thanks again
Bayezid


On Mon, May 19, 2014 at 10:03 AM, Dakota <waltherlalk@gmail.com> wrote:
The line echo $this->Form->input('username', ['options' => $pUser]); should be 'user_id'. Also, if the variable is 'users' cakephp will automatically pick it up as the options for the field.

Check that your created field allows null with default null.

--
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.

--
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.



--
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.

--
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: