Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

JavaScript Forum


You are currently viewing our JavaScript Forum as a guest. Please register to participate.
Login



Reply
Help needed. Probably something simple..
Old 03-21-2009, 01:32 AM Help needed. Probably something simple..
Junior Talker

Posts: 1
Trades: 0
Hey.

I need your help. I want to include a countdown timer in my site but I need some help with changing the html code.

the timer can be found here: http://www.oneplusyou.com/bb/countdown

it generates the html code but the maximum countdown is until 2010. I need the countdown to be until 2012. is that possible?

Your help will be greatly appreciated.

Mike
ftesology is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 03-21-2009, 01:50 AM Re: Help needed. Probably something simple..
konetch's Avatar
Ultra Talker

Posts: 258
Trades: 0
Hey. I'm not sure how to fix that script. You can use a much simpler javascipt. like this one...

Code:
<script>
 
//change the text below to reflect your own,
var before="Christmas!"
var current="Today is Christmas. Go cook some lamb!"
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
function countdown(yr,m,d){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy
var futurestring=montharray[m-1]+" "+d+", "+yr
var difference=(Math.round((Date.parse(futurestring)-Date.parse(todaystring))/(24*60*60*1000))*1)
if (difference==0)
document.write(current)
else if (difference>0)
document.write("Only "+difference+" days until "+before)
}
//enter the count down date using the format year/month/day
countdown(2012,12,25)
</script>
I don't know if you need something a little more exciting, and if you want a client side countdown you can try this.

Code:
<?php
// countdown function
// parameters: (year, month, day, hour, minute)
countdown(2010,1,1,0,0);
//--------------------------
function countdown($year, $month, $day, $hour, $minute)
{
  // make a unix timestamp for the given date
  $the_countdown_date = mktime($hour, $minute, 0, $month, $day, $year, -1);
  // get current unix timestamp
  $today = time();
  $difference = $the_countdown_date - $today;
  if ($difference < 0) $difference = 0;
  $days_left = floor($difference/60/60/24);
  $hours_left = floor(($difference - $days_left*60*60*24)/60/60);
  $minutes_left = floor(($difference - $days_left*60*60*24 - $hours_left*60*60)/60);
 
  // OUTPUT
  echo "Today's date ".date("F j, Y, g:i a")."<br/>";
  echo "Countdown date ".date("F j, Y, g:i a",$the_countdown_date)."<br/>";
  echo "Countdown ".$days_left." days ".$hours_left." hours ".$minutes_left." minutes left";
}
?>
Hope this helps.

__________________________________
http://www.konetchreport.com
konetch is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Help needed. Probably something simple..
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.10187 seconds with 12 queries