php - Weird timezone issue
So when I run
SELECT NOW()
I get
2021-01-09 21:30:00
When I run
SET time_zone = '-0:00';
SELECT NOW()
I get
2021-01-09 18:30:00
When I save something to my table via PHP data() in the DATETIME type column, I get
2021-01-09 18:30:00
Next, when I run
SET time_zone = '-0:00';
select * from ip_logging where DATE(date) > now() - interval 100 minute
I get nothing. If I don't use "SET time_zone" - same thing.
But when I run
SET time_zone = '-0:00';
select * from ip_logging where DATE(date) > now() - interval 1000 minute
I get my results in the interval of 1000 minutes (even tho my last row is saved 1 minute ago)
What am I doing wrong here?....
Answer
Solution:
This worked for me to get rows added in the last 10 minutes:
SET time_zone = '-0:00';
SELECT * FROM ip_logging WHERE date >= NOW() - INTERVAL 10 MINUTE
Source