Jump to content

count down


user4fun

Recommended Posts

$target = mktime(0, 0, 0, 1, 13, 2008);$today = time ();$difference =($target-$today);$days =(int) ($difference/86400);print "Our event will occur in $days days";

This is my starting point to have a count downAny one has a link to make itincludedayshoursminutessecondsand the code to be counting down as the user is browsing the page.

Link to comment
Share on other sites

Any one has a link to make itincludedayshoursminutessecondsand the code to be counting down as the user is browsing the page.
Use PHP to pass the vars to JavaScript, something like
<script type="text/javascript">var target = <?php echo mktime(0, 0, 0, 1, 13, 2008); ?>;function countdown() {today = new Date();now = today.getTime() / 1000;difference = target - now;days = Math.floor(difference / (60 * 60 * 24));difference -= days * 60 * 60 * 24;hours = Math.floor(difference / (60 * 60));difference -= hours * 60 * 60;minutes = Math.floor(difference / 60);difference -= minutes * 60;seconds = Math.floor(difference);document.getElementById('display_time').innerHTML = "Our event will occur in " + days + " days, " + hours + " hours, " + minutes + " minutes and " + seconds + "seconds.";}window.onload = function() { setInterval("countdown()", 1000); }</script>

And have an element with ID display_time to show the time.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...