Closed bjornpost closed 8 years ago
Thoughts, @jud @lox?
@bjornpost I think this would be something to document, but not do automatically.
@Jud why not do this automatically? I think it reduces the chance of unwanted/unpredictable side effects?
Might be best to follow suit and do something like ActiveRecord's config.active_record.default_timezone
, which may either be set to :utc
or :local
.
Could allow the option to be set when doing Pheasant::setup
.
That reminds me why I've always avoided mysql timestamps :)
I think @Jud's suggestion is the right approach, I'd have a timezone somewhere for the database connection (set it here https://github.com/lox/pheasant/blob/master/lib/Pheasant/Database/Mysqli/Connection.php#L125) and then use that to correctly unmarshal timestamp's into the right tz.
Closing this for now.
Our configuration:
date_default_timezone_set('Europe/Amsterdam');
@@global.time_zone=UTC
,@@session.time_zone=UTC
When 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, so2015-06-30 15:38:29
becomes2015-06-30 15:38:29+02:00
. Whoops :-).Right now, when connecting, I'm setting the correct timezone:
@@session.time_zone
when unmarshalling DateTime's?Thoughts?