开发者

Exact time remaining to next quiz

开发者 https://www.devze.com 2023-03-03 13:33 出处:网络
I can get only the currently on开发者_JS百科going quiz. How to display the exact time only until the next quiz?

I can get only the currently on开发者_JS百科going quiz. How to display the exact time only until the next quiz?

Exact time remaining to next quiz


I don't know, whether I got your question right: "I can get only the currently ongoing quiz." Does that mean, you have the ID of the currently ongoing quiz or that you can determine this quiz by comparing its start and end with the current time?

In first case, you can do:

SELECT *, TIMEDIFF(b.start, a.end)
FROM <table> AS a
LEFT JOIN <table> AS b ON b.id_quiz <> a.id_quiz AND b.start > a.end
WHERE a.id_quiz = <current quiz id>
ORDER BY b.start ASC
LIMIT 1

In second case, it's even easier:

SELECT *, TIMEDIFF(x.start, NOW())
FROM <table> AS x
WHERE x.start > NOW()
ORDER BY x.start ASC
LIMIT 1


subtract now from start?

-(now()-start)?
0

精彩评论

暂无评论...
验证码 换一张
取 消