Reputation: 11
I am new to cakePHP.
Currently I am facing this trouble, it show me this error when I login to cakePHP project.
**Database Error**
Error: SQLSTATE[22007]: Invalid datetime format: 1292 Incorrect datetime value: '2015-10-22T15:42:20+08:00' for column 'last_login' at row 1
SQL Query: UPDATE `cakephpdb`.`users` SET `last_login` = '2015-10-22T15:42:20+08:00', `modified` = '2015-10-22 15:42:20' WHERE `cakephpdb`.`users`.`id` = '37'
I think this can be configure in cakePHP config file (which just edit in 1 file that can affect the entire project) or maybe change the MySQL setting.
Below is detail:
Many thanks for help! Thank you.
Upvotes: 1
Views: 2468
Reputation: 25698
Invalid datetime format: 1292 Incorrect datetime value: '2015-10-22T15:42:20+08:00'
Pass the correct datetime format: YYY-MM-DD HH:MM:SS
This is what I would assume the field expects. Use date()
to reformat your date or the DateTime
class of whatever CakePHP version you're using.
Upvotes: 3
Reputation: 11
Very weird that if I am using XAMPP at localhost, it can be store perfectly. But when I launch in live (using IIS), it can't store with this datetime format "2015-10-22T15:42:20+08:00".
So I found out that cakePHP is using:
date(DATE_ATOM)
I change it to:
date('Y-m-d H:i:s')
now is it worked.
Thanks to @burzum and @Chandresh. :)
Upvotes: 0
Reputation: 3828
I think here is the format of datatime you are trying to pass is the issue.
Make it change with PHP date function in proper format (YYYY-MM-DD HH:MM:SS).
date('Y-m-d H:i:s',strtotime($yourdate));
I think this will work in this case.
Thanks.
Upvotes: 0