{"action":"created","issue":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/8305","labels_url":"https://api.github.com/repos/yiisoft/yii2/issues/8305/labels{/name}","comments_url":"https://api.github.com/repos/yiisoft/yii2/issues/8305/comments","events_url":"https://api.github.com/repos/yiisoft/yii2/issues/8305/events","html_url":"https://github.com/yiisoft/yii2/issues/8305","id":73730735,"number":8305,"title":"Unexpected character in \\vendor\\yiisoft\\yii2\\i18n\\Formatter.php","user":{"login":"cbhp","id":5774444,"avatar_url":"https://avatars.githubusercontent.com/u/5774444?v=3","gravatar_id":"","url":"https://api.github.com/users/cbhp","html_url":"https://github.com/cbhp","followers_url":"https://api.github.com/users/cbhp/followers","following_url":"https://api.github.com/users/cbhp/following{/other_user}","gists_url":"https://api.github.com/users/cbhp/gists{/gist_id}","starred_url":"https://api.github.com/users/cbhp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbhp/subscriptions","organizations_url":"https://api.github.com/users/cbhp/orgs","repos_url":"https://api.github.com/users/cbhp/repos","events_url":"https://api.github.com/users/cbhp/events{/privacy}","received_events_url":"https://api.github.com/users/cbhp/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/yiisoft/yii2/labels/status:under%20discussion","name":"status:under discussion","color":"f7c6c7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2015-05-06T20:36:28Z","updated_at":"2015-05-06T21:08:51Z","closed_at":null,"body":"I use Optimistic Locks (yii\\db\\StaleObjectException).\r\n\r\nHere is an example of the problematic controller action:\r\n```\r\npublic function actionPublish($id)\r\n{\r\n\t$model = $this->findModel($id);\r\n\t$model->scenario = 'publish';\r\n\t\r\n\tif ($model->load(Yii::$app->request->post())) {\r\n\t\t\r\n\t\t$model->published = new yii\\db\\Expression('NOW()');\r\n\t\t\r\n\t\ttry {\r\n\t\t\tif ($model->save()) {\r\n\t\t\t\treturn $this->redirect(['view', 'id' => $model->id]);\r\n\t\t\t}\r\n\t\t} catch (yii\\db\\StaleObjectException $e) {\r\n\t\t\tYii::$app->session->setFlash('danger', 'Since your last view there was a change. Here you see your last edits for saving to clipboard.');\r\n\t\t}\r\n\t}\r\n\t\r\n\treturn $this->render('view', ['model' => $model]);\r\n}\r\n```\r\nview.php:\r\n```\r\n<?= DetailView::widget([\r\n\t'model' => $model,\r\n\t'attributes' => [\r\n\t\t// ...\r\n\t\t'published:datetime',\r\n\t\t// ...\r\n\t],\r\n]) ?>\r\n```\r\n\r\nIf no changes has been made meanwhile, saving the model succeeds. \r\n\r\nIf there was a change, the StaleObjectException is raised (correctly). But the view breaks:\r\n```\r\nInvalid Parameter – yii\\base\\InvalidParamException 'NOW()' is not a valid date time value: DateTime::__construct(): Failed to parse time string (NOW()) at position 3 ((): Unexpected character\r\nin \\vendor\\yiisoft\\yii2\\i18n\\Formatter.php at line 639\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/yiisoft/yii2/issues/comments/99610332","html_url":"https://github.com/yiisoft/yii2/issues/8305#issuecomment-99610332","issue_url":"https://api.github.com/repos/yiisoft/yii2/issues/8305","id":99610332,"user":{"login":"cbhp","id":5774444,"avatar_url":"https://avatars.githubusercontent.com/u/5774444?v=3","gravatar_id":"","url":"https://api.github.com/users/cbhp","html_url":"https://github.com/cbhp","followers_url":"https://api.github.com/users/cbhp/followers","following_url":"https://api.github.com/users/cbhp/following{/other_user}","gists_url":"https://api.github.com/users/cbhp/gists{/gist_id}","starred_url":"https://api.github.com/users/cbhp/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cbhp/subscriptions","organizations_url":"https://api.github.com/users/cbhp/orgs","repos_url":"https://api.github.com/users/cbhp/repos","events_url":"https://api.github.com/users/cbhp/events{/privacy}","received_events_url":"https://api.github.com/users/cbhp/received_events","type":"User","site_admin":false},"created_at":"2015-05-06T21:08:51Z","updated_at":"2015-05-06T21:08:51Z","body":"Thank you for the advice. \r\nIs it an expected behavior of the Formatter (`'published:datetime'`) to raise an exception if the value could not be parsed? "}}