Number of seconds until every 20 minutes
For a game I'm making, each turn is at :00, :20, and :4开发者_Python百科0 past the hour. I am trying to create a countdown that will display the number of minutes (and eventually seconds) to the next turn.
My current approach is to store the time of the next turn in a database, then doing
$time = time() - $time_to_turn
where time_to_turn
is the database entry of the next turn time.
Is there a way to not use the database?
Try $minutesRemaining = 20 - date('i') % 20;
or $secondsRemaining = 1200 - date('s') % 1200
精彩评论