I've set my timezone to pacific/auckland in my PHP ini file. when I echo the time() in date format it's correct.
How can I retrieve records where 'datetime' is past this time when the MySQL server time (which I can't change) is differnt?
MySQL DateTime: 2021-11-10 11:50:00.000000
I've tried this
WHERE UNIX_TIMESTAMP(CONVERT_TZ(`myDateTimeCol`, 'NZT', 'CST')) <= 1637227300
I don't have access to MySQL, but I think you could just specify TZ in your value being compared, e.g.:
WHERE myDateTimeCol <= '2021-11-18 12:34:56+12:00'
You should be able to get your PHP to generate that string via date():
$where_date = date('Y-m-d H:i:sP');
Yes I had it in my head I needed to convert my PHP to unix timestamp based on my MYSQL server time or covert the SQL time to NZ time. But in fact I just needed to compare the fixed string in the database against a created string from PHP.
Hello, it is enough to compare the set string in the database with the string created with PHP, I had it too, but I compared it and now it is very good, as it should, I was wondering for a long time how to do it, but finally it worked