php - How to get days,hours,minutes,seconds left for an event with different timezone through mysql query

141

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');
757

Answer

Solution:

You can set thetime_zone on the mysql session before you execute the query:

SET time_zone = '+20:00';

You can read more here.

People are also looking for solutions to the problem: replace every second comma of string using php

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.