I was 100% certain that timestamps in my database are in UTC, but following last night's shift to GMT I seem to have evidence to the contrary in my 15 minute temperature records.
select id, timestamp, temperature from doorsensor where id between 4933 and 4945;
+------+---------------------+-------------+
| id | timestamp | temperature |
+------+---------------------+-------------+
| 4933 | 2024-10-27 00:25:28 | 12.7 |
| 4934 | 2024-10-27 00:40:28 | 12.7 |
| 4935 | 2024-10-27 00:55:28 | 12.7 |
| 4936 | 2024-10-27 01:10:28 | 12.7 | }
| 4937 | 2024-10-27 01:25:28 | 12.7 | }
| 4938 | 2024-10-27 01:40:28 | 12.7 | }
| 4939 | 2024-10-27 01:55:28 | 12.7 | }
| 4940 | 2024-10-27 01:10:28 | 12.7 | ****** Repeated timestamps
| 4941 | 2024-10-27 01:25:28 | 12.7 |
| 4942 | 2024-10-27 01:40:28 | 12.8 |
| 4943 | 2024-10-27 01:55:28 | 12.9 |
| 4944 | 2024-10-27 02:10:28 | 12.8 |
| 4945 | 2024-10-27 02:25:28 | 12.8 |
This is my table definition, note timestamp default now()
CREATE TABLE `doorsensor` (
`id` int(11) NOT NULL AUTO_INCREMENT,
timestamp datetime not null default now(),
temperature float null,
humidity float null,
dewpoint float null,
pressure float null,
seapressure float null,
gas float null,
PRIMARY KEY (`id`)
);
And the INSERT statement
newmsg.topic = "insert into doorsensor"
newmsg.topic += "(temperature, humidity, dewpoint, pressure, seapressure, gas)"
newmsg.topic += "VALUES(:temperature, :humidity, :dewpoint, :pressure, :seapressure, :gas)"
How come the duplicated timestamps?
What do I need to change to store data in UTC?