Skip to content

Instantly share code, notes, and snippets.

@tanakahisateru
Created December 10, 2014 08:56
Show Gist options
  • Save tanakahisateru/15488cfd13a4fc9bf9ee to your computer and use it in GitHub Desktop.
Save tanakahisateru/15488cfd13a4fc9bf9ee to your computer and use it in GitHub Desktop.
日本のクリスマスは世界のクリスマスイブ
CREATE TABLE test (
day1 DATETIME,
day2 TIMESTAMP
);
SET SESSION time_zone = 'UTC';
INSERT INTO test VALUES ('2014-12-25 00:00:00', '2014-12-25 00:00:00');
SET SESSION time_zone = 'Asia/Tokyo';
INSERT INTO test VALUES ('2014-12-25 00:00:00', '2014-12-25 00:00:00');
SET SESSION time_zone = 'UTC';
SELECT * FROM test;
-- day1 day2
-- 2014-12-25 00:00:00 2014-12-25 00:00:00
-- 2014-12-25 00:00:00 2014-12-24 15:00:00
@tanakahisateru
Copy link
Author

さらにアプリケーションで受けたときもうDBの型失われてる問題。
ユーザーのロケールによって時差補正するとかどうしたら...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment