I need to update all rows in my events table. There is an event_date column with a timestamp type.
But if I update each row ( event_date column) with a new date (expample: 2015-12-12 12:00:00), then I have several rows with a value of 2015-12-12 13:00:00.
Point - why are some lines correct and some + 1h?
In PHP, I use the Nette framework and its DateTime object, which extends the standard PHP DateTime ...
Any ideas, clues, why is this happening?
EDIT: The query is as follows:
UPDATE `events` SET `event_date`='2016-2-13 12:00:00', `event_date_to`=NULL WHERE (`id` = 203)
The values ββin php i am are set as follows:
$row->event_date = date("Ymd H:i:s", $oldRow['event_date']);
The problem starts earlier - in this table there were dates like 2016-2-13 00:00:00, but after the selection and echo dates changed to 2016-2-12 23:00:00 - but not all the lines ... only to whom something. Therefore, I make a choice:
select events.id, events.event_date, events.event_date_to, concat(year(event_date), '-', month(event_date), '-', day(event_date), ' 12:00:00') as new_event_date, IF(events.event_date_to IS NULL,null, concat(year(event_date_to), '-', month(event_date_to), '-', day(event_date_to), ' 12:00:00')) as new_event_date_to from events
To select such rows, follow these steps:
769,2014-04-22 19:30:00,2014-04-22 21:45:00,2014-4-22 12:00:00,2014-4-22 12:00:00
This means: id, event_date (real db value), event_date_to (real db value), event_date (new value to insert), event_date_to (new value to insert - may be NULL)
And saved to the csv file ... I am parsing this file now and in foreach I update every line ...
I checked ALL QUESTIONS and the time is OK (12:00:00), so I do not understand and got stuck :)