php - How to get days,hours,minutes,seconds left for an event with different timezone through mysql query
My server has a timezone of US .Need to generate the JSON response from PHP for IST timings showing the days,hours,minutes,seconds left for some event. I know it can be done using the PHP . I want to know if there is anyway to if I can get the same via mysql query like
I have an even in a table
EVENT - Diwali
event_date - 3 November 2013
and today is 22nd and 2:30 IST time.
If I make a query like below
select `events`, event_date from events_table where DAY(STR_TO_DATE(event_date, '%y-%m-%d')) >DAY(CURDATE())
how can get the days,hours,minutes with IST timezone? Is this is achievable through query ?
Solution
SELECT CONVERT_TZ(NOW(),@@session.time_zone, '+05:30');
Answer
Solution:
You can set the
time_zone
on the mysql session before you execute the query:You can read more here.