1
drop table if exists t1, t2;
2
drop function if exists f1;
3
create table t1 (ts timestamp);
4
set time_zone='+00:00';
5
select unix_timestamp(utc_timestamp())-unix_timestamp(current_timestamp());
6
unix_timestamp(utc_timestamp())-unix_timestamp(current_timestamp())
8
insert into t1 (ts) values ('2003-03-30 02:30:00');
9
set time_zone='+10:30';
10
select unix_timestamp(utc_timestamp())-unix_timestamp(current_timestamp());
11
unix_timestamp(utc_timestamp())-unix_timestamp(current_timestamp())
13
insert into t1 (ts) values ('2003-03-30 02:30:00');
14
set time_zone='-10:00';
15
select unix_timestamp(utc_timestamp())-unix_timestamp(current_timestamp());
16
unix_timestamp(utc_timestamp())-unix_timestamp(current_timestamp())
18
insert into t1 (ts) values ('2003-03-30 02:30:00');
25
select Name from mysql.time_zone_name where Name in
26
('UTC','Universal','MET','Europe/Moscow','leap/Europe/Moscow');
33
create table t1 (i int, ts timestamp);
35
insert into t1 (i, ts) values
36
(unix_timestamp('2003-03-01 00:00:00'),'2003-03-01 00:00:00');
37
insert into t1 (i, ts) values
38
(unix_timestamp('2003-03-30 01:59:59'),'2003-03-30 01:59:59'),
39
(unix_timestamp('2003-03-30 02:30:00'),'2003-03-30 02:30:00'),
40
(unix_timestamp('2003-03-30 03:00:00'),'2003-03-30 03:00:00');
42
Warning 1299 Invalid TIMESTAMP value in column 'ts' at row 2
43
insert into t1 (i, ts) values
44
(unix_timestamp(20030330015959),20030330015959),
45
(unix_timestamp(20030330023000),20030330023000),
46
(unix_timestamp(20030330030000),20030330030000);
48
Warning 1299 Invalid TIMESTAMP value in column 'ts' at row 2
49
insert into t1 (i, ts) values
50
(unix_timestamp('2003-05-01 00:00:00'),'2003-05-01 00:00:00');
51
insert into t1 (i, ts) values
52
(unix_timestamp('2003-10-26 01:00:00'),'2003-10-26 01:00:00'),
53
(unix_timestamp('2003-10-26 02:00:00'),'2003-10-26 02:00:00'),
54
(unix_timestamp('2003-10-26 02:59:59'),'2003-10-26 02:59:59'),
55
(unix_timestamp('2003-10-26 04:00:00'),'2003-10-26 04:00:00'),
56
(unix_timestamp('2003-10-26 02:59:59'),'2003-10-26 02:59:59');
60
1046473200 2003-02-28 23:00:00
61
1048985999 2003-03-30 00:59:59
62
1048986000 2003-03-30 01:00:00
63
1048986000 2003-03-30 01:00:00
64
1048985999 2003-03-30 00:59:59
65
1048986000 2003-03-30 01:00:00
66
1048986000 2003-03-30 01:00:00
67
1051740000 2003-04-30 22:00:00
68
1067122800 2003-10-25 23:00:00
69
1067126400 2003-10-26 00:00:00
70
1067129999 2003-10-26 00:59:59
71
1067137200 2003-10-26 03:00:00
72
1067129999 2003-10-26 00:59:59
74
set time_zone='Europe/Moscow';
75
insert into t1 (i, ts) values
76
(unix_timestamp('2004-01-01 00:00:00'),'2004-01-01 00:00:00'),
77
(unix_timestamp('2004-03-28 02:30:00'),'2004-03-28 02:30:00'),
78
(unix_timestamp('2004-08-01 00:00:00'),'2003-08-01 00:00:00'),
79
(unix_timestamp('2004-10-31 02:30:00'),'2004-10-31 02:30:00');
81
Warning 1299 Invalid TIMESTAMP value in column 'ts' at row 2
84
1072904400 2004-01-01 00:00:00
85
1080428400 2004-03-28 03:00:00
86
1091304000 2003-08-01 00:00:00
87
1099175400 2004-10-31 02:30:00
89
set time_zone='leap/Europe/Moscow';
90
insert into t1 (i, ts) values
91
(unix_timestamp('2004-01-01 00:00:00'),'2004-01-01 00:00:00'),
92
(unix_timestamp('2004-03-28 02:30:00'),'2004-03-28 02:30:00'),
93
(unix_timestamp('2004-08-01 00:00:00'),'2003-08-01 00:00:00'),
94
(unix_timestamp('2004-10-31 02:30:00'),'2004-10-31 02:30:00');
96
Warning 1299 Invalid TIMESTAMP value in column 'ts' at row 2
99
1072904422 2004-01-01 00:00:00
100
1080428422 2004-03-28 03:00:00
101
1091304022 2003-08-01 00:00:00
102
1099175422 2004-10-31 02:30:00
104
insert into t1 (i, ts) values
105
(unix_timestamp('1981-07-01 03:59:59'),'1981-07-01 03:59:59'),
106
(unix_timestamp('1981-07-01 04:00:00'),'1981-07-01 04:00:00');
109
362793608 1981-07-01 03:59:59
110
362793610 1981-07-01 04:00:00
111
select from_unixtime(362793609);
112
from_unixtime(362793609)
115
create table t1 (ts timestamp);
117
insert into t1 values ('0000-00-00 00:00:00'),('1969-12-31 23:59:59'),
118
('1970-01-01 00:00:00'),('1970-01-01 00:00:01'),
119
('2038-01-19 03:14:07'),('2038-01-19 03:14:08');
121
Warning 1264 Out of range value for column 'ts' at row 2
122
Warning 1264 Out of range value for column 'ts' at row 3
123
Warning 1264 Out of range value for column 'ts' at row 6
134
insert into t1 values ('0000-00-00 00:00:00'),('1970-01-01 00:30:00'),
135
('1970-01-01 01:00:00'),('1970-01-01 01:00:01'),
136
('2038-01-19 04:14:07'),('2038-01-19 04:14:08');
138
Warning 1264 Out of range value for column 'ts' at row 2
139
Warning 1264 Out of range value for column 'ts' at row 3
140
Warning 1264 Out of range value for column 'ts' at row 6
150
set time_zone='+01:30';
151
insert into t1 values ('0000-00-00 00:00:00'),('1970-01-01 01:00:00'),
152
('1970-01-01 01:30:00'),('1970-01-01 01:30:01'),
153
('2038-01-19 04:44:07'),('2038-01-19 04:44:08');
155
Warning 1264 Out of range value for column 'ts' at row 2
156
Warning 1264 Out of range value for column 'ts' at row 3
157
Warning 1264 Out of range value for column 'ts' at row 6
167
show variables like 'time_zone';
170
set time_zone = default;
171
show variables like 'time_zone';
175
ERROR HY000: Unknown or incorrect time zone: '0'
176
set time_zone= '0:0';
177
ERROR HY000: Unknown or incorrect time zone: '0:0'
178
set time_zone= '-20:00';
179
ERROR HY000: Unknown or incorrect time zone: '-20:00'
180
set time_zone= '+20:00';
181
ERROR HY000: Unknown or incorrect time zone: '+20:00'
182
set time_zone= 'Some/Unknown/Time/Zone';
183
ERROR HY000: Unknown or incorrect time zone: 'Some/Unknown/Time/Zone'
184
select convert_tz(now(),'UTC', 'Universal') = now();
185
convert_tz(now(),'UTC', 'Universal') = now()
187
select convert_tz(now(),'utc', 'UTC') = now();
188
convert_tz(now(),'utc', 'UTC') = now()
190
select convert_tz('1917-11-07 12:00:00', 'MET', 'UTC');
191
convert_tz('1917-11-07 12:00:00', 'MET', 'UTC')
193
select convert_tz('1970-01-01 01:00:00', 'MET', 'UTC');
194
convert_tz('1970-01-01 01:00:00', 'MET', 'UTC')
196
select convert_tz('1970-01-01 01:00:01', 'MET', 'UTC');
197
convert_tz('1970-01-01 01:00:01', 'MET', 'UTC')
199
select convert_tz('2003-03-01 00:00:00', 'MET', 'UTC');
200
convert_tz('2003-03-01 00:00:00', 'MET', 'UTC')
202
select convert_tz('2003-03-30 01:59:59', 'MET', 'UTC');
203
convert_tz('2003-03-30 01:59:59', 'MET', 'UTC')
205
select convert_tz('2003-03-30 02:30:00', 'MET', 'UTC');
206
convert_tz('2003-03-30 02:30:00', 'MET', 'UTC')
208
select convert_tz('2003-03-30 03:00:00', 'MET', 'UTC');
209
convert_tz('2003-03-30 03:00:00', 'MET', 'UTC')
211
select convert_tz('2003-05-01 00:00:00', 'MET', 'UTC');
212
convert_tz('2003-05-01 00:00:00', 'MET', 'UTC')
214
select convert_tz('2003-10-26 01:00:00', 'MET', 'UTC');
215
convert_tz('2003-10-26 01:00:00', 'MET', 'UTC')
217
select convert_tz('2003-10-26 02:00:00', 'MET', 'UTC');
218
convert_tz('2003-10-26 02:00:00', 'MET', 'UTC')
220
select convert_tz('2003-10-26 02:59:59', 'MET', 'UTC');
221
convert_tz('2003-10-26 02:59:59', 'MET', 'UTC')
223
select convert_tz('2003-10-26 04:00:00', 'MET', 'UTC');
224
convert_tz('2003-10-26 04:00:00', 'MET', 'UTC')
226
select convert_tz('2038-01-19 04:14:07', 'MET', 'UTC');
227
convert_tz('2038-01-19 04:14:07', 'MET', 'UTC')
229
select convert_tz('2038-01-19 04:14:08', 'MET', 'UTC');
230
convert_tz('2038-01-19 04:14:08', 'MET', 'UTC')
232
select convert_tz('2103-01-01 04:00:00', 'MET', 'UTC');
233
convert_tz('2103-01-01 04:00:00', 'MET', 'UTC')
235
create table t1 (tz varchar(3));
236
insert into t1 (tz) values ('MET'), ('UTC');
237
select tz, convert_tz('2003-12-31 00:00:00',tz,'UTC'), convert_tz('2003-12-31 00:00:00','UTC',tz) from t1 order by tz;
238
tz convert_tz('2003-12-31 00:00:00',tz,'UTC') convert_tz('2003-12-31 00:00:00','UTC',tz)
239
MET 2003-12-30 23:00:00 2003-12-31 01:00:00
240
UTC 2003-12-31 00:00:00 2003-12-31 00:00:00
242
select convert_tz('2003-12-31 04:00:00', NULL, 'UTC');
243
convert_tz('2003-12-31 04:00:00', NULL, 'UTC')
245
select convert_tz('2003-12-31 04:00:00', 'SomeNotExistingTimeZone', 'UTC');
246
convert_tz('2003-12-31 04:00:00', 'SomeNotExistingTimeZone', 'UTC')
248
select convert_tz('2003-12-31 04:00:00', 'MET', 'SomeNotExistingTimeZone');
249
convert_tz('2003-12-31 04:00:00', 'MET', 'SomeNotExistingTimeZone')
251
select convert_tz('2003-12-31 04:00:00', 'MET', NULL);
252
convert_tz('2003-12-31 04:00:00', 'MET', NULL)
254
select convert_tz( NULL, 'MET', 'UTC');
255
convert_tz( NULL, 'MET', 'UTC')
257
create table t1 (ts timestamp);
258
set timestamp=1000000000;
259
insert into t1 (ts) values (now());
260
select convert_tz(ts, @@time_zone, 'Japan') from t1;
261
convert_tz(ts, @@time_zone, 'Japan')
264
select convert_tz('2005-01-14 17:00:00', 'UTC', custTimeZone) from (select 'UTC' as custTimeZone) as tmp;
265
convert_tz('2005-01-14 17:00:00', 'UTC', custTimeZone)
267
create table t1 select convert_tz(NULL, NULL, NULL);
269
convert_tz(NULL, NULL, NULL)
272
SET GLOBAL log_bin_trust_function_creators = 1;
273
create table t1 (ldt datetime, udt datetime);
274
create function f1(i datetime) returns datetime
275
return convert_tz(i, 'UTC', 'Europe/Moscow');
276
create trigger t1_bi before insert on t1 for each row
277
set new.udt:= convert_tz(new.ldt, 'Europe/Moscow', 'UTC');
278
insert into t1 (ldt) values ('2006-04-19 16:30:00');
281
2006-04-19 16:30:00 2006-04-19 12:30:00
282
select ldt, f1(udt) as ldt2 from t1;
284
2006-04-19 16:30:00 2006-04-19 16:30:00
287
SET GLOBAL log_bin_trust_function_creators = 0;
288
DROP TABLE IF EXISTS t1;
289
CREATE TABLE t1 (t TIMESTAMP);
290
INSERT INTO t1 VALUES (NULL), (NULL);
291
LOCK TABLES t1 WRITE;
292
SELECT CONVERT_TZ(NOW(), 'UTC', 'Europe/Moscow') IS NULL;
293
CONVERT_TZ(NOW(), 'UTC', 'Europe/Moscow') IS NULL
295
UPDATE t1 SET t = CONVERT_TZ(t, 'UTC', 'Europe/Moscow');