0

Currently I have a query where I check data against the current date and current time:

SELECT ...
FROM ...
WHERE ...
AND DATE(event_date ) = '".$cur_date."'
AND event_time > '" . $cur_time . "'

where

$cur_date = date('Y-m-d');
$cur_time = date('H:i');

However, we just added additional column to the db table that contains UTC time offset, expressed in minutes, currently: -300

I need to adjust the query to reflect the adjustment. Not really sure how to do it in mySQL. In PHP I just do something like this:

date('g:i A', strtotime($event_date) + ($offset_time * 60)); 

My db is located on a different server. The only way to know it's relative time to my user location is via UTC time offset.

santa
  • 12,234
  • 49
  • 155
  • 255

2 Answers2

0

use MySQL CURDATE(),CURTIME()

SELECT FROM table 
WHERE 
AND DATE(event_date) = CURDATE()
AND event_time > CURTIME()
Abhishek Sharma
  • 6,689
  • 1
  • 14
  • 20
0

First you set time zone of mysql :-

SET GLOBAL time_zone = '+5:00';//your time_zone
SET GLOBAL time_zone = 'Europe/Helsinki';//your time_zone name
SET @@global.time_zone='+00:00';
Abhishek Sharma
  • 6,689
  • 1
  • 14
  • 20