Skip to content

Instantly share code, notes, and snippets.

@chen206
Created March 18, 2016 05:19
Show Gist options
  • Save chen206/72fc51ac3272e70f85de to your computer and use it in GitHub Desktop.
Save chen206/72fc51ac3272e70f85de to your computer and use it in GitHub Desktop.
MySQL日期时间时区
CREATE TABLE `tbl_test` (
`id` int(11) unsigned NOT NULL AUTO_INCREMENT,
`ts` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=1 DEFAULT CHARSET=utf8;
SELECT @@session.time_zone;
SELECT @@global.time_zone;
SET @@session.time_zone='+08:00';
INSERT INTO tbl_test (ts) VALUES ('2016-01-26 19:35:24');
SET @@session.time_zone='+02:00';
SELECT * FROM tbl_test;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment