jkgfkasdjgfasjkdgh
jkgfkasdjgfasjkdgh

Reputation: 81

mysql datetime problem "Incorrect datetime value" and daylight savings

I have a problem storing a date/time. i.e.

DBD::mysql::st execute failed: Incorrect datetime value: '2022-03-27 01:00:00' for column smets2.electricity.time

Now the only possible thing I can see wrong with this is that perhaps this time does not exist because of daylight savings. 01:00:00 became 02:00:00

Here's the SQL I used to create the table

create table if not exists electricity (time timestamp null, consumption double);

So my question are ...

  1. does mysql understand about daylight savings by default ?
  2. What is the correct date/time for this time. Clearly it cannot be '2022-03-27 01:00:00', should it be '2022-03-27 02:00:00'
  3. how can I force mysql to use UTC for date/time

Thanks

Upvotes: 2

Views: 1359

Answers (1)

jkgfkasdjgfasjkdgh
jkgfkasdjgfasjkdgh

Reputation: 81

OK.

It seems that the problem is that I defined the field a 'timestamp' when it should have been 'datetime'.

'timestamp' fields get the timezone applied on input/output.

Won't make that mistake again :-)

Upvotes: 2

Related Questions