user4fun Posted December 16, 2007 Share Posted December 16, 2007 $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 More sharing options...
Synook Posted December 16, 2007 Share Posted December 16, 2007 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 More sharing options...
clonetrooper9494 Posted December 17, 2007 Share Posted December 17, 2007 I have a Xmas script, feel free to use it alter it to your needs:http://free.hostultra.com/~clonetrooper/Xmas.html Link to comment Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.