Soldato
- Joined
- 7 Jan 2007
- Posts
- 10,607
- Location
- Sussex, UK
Found this cool PHP code on the interwebs which is ideal, it offers me a weekly countdown timer, but how would I adapt this to show hours left to buy a ticket on the last day?
At the moment it says tickets closed on the last day, but I want it to count down evey hour to a set time on the last day.
Can anyone help?
At the moment it says tickets closed on the last day, but I want it to count down evey hour to a set time on the last day.
Can anyone help?
PHP:
<?php
$interval = 3; // number of days between ticket sales
$launch_date = strtotime('22 January 2011'); // fill in
$days = floor((time() - $launch_date)/86400) % $interval;
if($days === 0)
{
echo 'Ticket sales are now closed';
}
else
{
echo '<p>Ticket sales close in '.((($days = $interval - $days)>($interval-1))?$days-$interval:$days).' days</p>';
}
?>