I am using a table with:
CREATE TABLE tv (
datetime datetime NOT NULL,
value int(4),
metric varchar(25),
PRIMARY KEY (datetime)
);
My system is in CET so I get this from a select:
select * from tv;
+---------------------+-------+----------+
| datetime | value | metric |
+---------------------+-------+----------+
| 2017-08-09 14:17:27 | 0 | TV power |
| 2017-08-09 14:20:04 | 0 | TV power |
| 2017-08-09 14:40:04 | 0 | TV power |
| 2017-08-09 14:45:03 | 0 | TV power |
When I try to graph it (in grafana), I use:
SELECT
UNIX_TIMESTAMP(datetime) as time_sec,
value,
metric
FROM tv
ORDER BY datetime
And it works fine except that it writes everything with 2 hours more in the future. So I guess this is because the UNIX_TIMESTAMP is thinking that the datetime is in UTC and looking at the system value, as it is CET, it is doing a +02:00 before converting to epoch or something like this.
I get this also:
SELECT @@global.time_zone;
+--------------------+
| @@global.time_zone |
+--------------------+
| SYSTEM |
+--------------------+
1 row in set (0.00 sec)
Meaning it is using the system timezone which is CET.
How can I get my UNIX_TIMESTAMP to convert correctly to the CET?
Thanks.