{"action":"created","issue":{"url":"https://api.github.com/repos/lox/pheasant/issues/152","labels_url":"https://api.github.com/repos/lox/pheasant/issues/152/labels{/name}","comments_url":"https://api.github.com/repos/lox/pheasant/issues/152/comments","events_url":"https://api.github.com/repos/lox/pheasant/issues/152/events","html_url":"https://github.com/lox/pheasant/issues/152","id":101478092,"number":152,"title":"Unmarshalling DateTime's when using different timezones","user":{"login":"bjornpost","id":48628,"avatar_url":"https://avatars.githubusercontent.com/u/48628?v=3","gravatar_id":"","url":"https://api.github.com/users/bjornpost","html_url":"https://github.com/bjornpost","followers_url":"https://api.github.com/users/bjornpost/followers","following_url":"https://api.github.com/users/bjornpost/following{/other_user}","gists_url":"https://api.github.com/users/bjornpost/gists{/gist_id}","starred_url":"https://api.github.com/users/bjornpost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjornpost/subscriptions","organizations_url":"https://api.github.com/users/bjornpost/orgs","repos_url":"https://api.github.com/users/bjornpost/repos","events_url":"https://api.github.com/users/bjornpost/events{/privacy}","received_events_url":"https://api.github.com/users/bjornpost/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2015-08-17T18:11:09Z","updated_at":"2015-08-20T07:02:16Z","closed_at":null,"body":"Our configuration:\r\n * App server: `date_default_timezone_set('Europe/Amsterdam');`\r\n * Database server: `@@global.time_zone=UTC`, `@@session.time_zone=UTC`\r\n\r\nWhen unmarshalling datetimes, a DateTime object is created with just the datetime string returned by MySQL (i.e. `2015-06-30 15:38:29`, which is `+0000`). As no TZ info is provided, PHP assumes the provided string is in the default_timezone, so `2015-06-30 15:38:29` becomes `2015-06-30 15:38:29+02:00`. Whoops :-).\r\n\r\nRight now, when connecting, I'm setting the correct timezone:\r\n\r\n    $p = \\Pheasant::setup('mysql://user:pass@host/table');\r\n    $p->connection()->execute(\"SET time_zone='\".date_default_timezone_get().\"';\");\r\n\r\n* Is this a query we should run by default?\r\n* Should we be less naive and provide the `@@session.time_zone` when unmarshalling DateTime's?\r\n\r\nThoughts?"},"comment":{"url":"https://api.github.com/repos/lox/pheasant/issues/comments/132913030","html_url":"https://github.com/lox/pheasant/issues/152#issuecomment-132913030","issue_url":"https://api.github.com/repos/lox/pheasant/issues/152","id":132913030,"user":{"login":"bjornpost","id":48628,"avatar_url":"https://avatars.githubusercontent.com/u/48628?v=3","gravatar_id":"","url":"https://api.github.com/users/bjornpost","html_url":"https://github.com/bjornpost","followers_url":"https://api.github.com/users/bjornpost/followers","following_url":"https://api.github.com/users/bjornpost/following{/other_user}","gists_url":"https://api.github.com/users/bjornpost/gists{/gist_id}","starred_url":"https://api.github.com/users/bjornpost/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bjornpost/subscriptions","organizations_url":"https://api.github.com/users/bjornpost/orgs","repos_url":"https://api.github.com/users/bjornpost/repos","events_url":"https://api.github.com/users/bjornpost/events{/privacy}","received_events_url":"https://api.github.com/users/bjornpost/received_events","type":"User","site_admin":false},"created_at":"2015-08-20T07:02:16Z","updated_at":"2015-08-20T07:02:16Z","body":"Thoughts, @jud @lox?"}}