SunQuest
           Client Side Things
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesClient Side Things

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Be the architects of evolution and help create the mobile internet future. It’s your move---enter to win here!
  #1  
Old March 16th, 2008, 01:41 AM
footballer footballer is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 73 footballer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 h 51 m 55 sec
Reputation Power: 1
Need help with to change Javascript Count Down

Hello,

I would like to change the display of this count down from looking like this: 93:42:34 Seconds

I want it to include a Day, something like: 4 Days 12 Hours 32 Seconds, if anyone could help that would be awesome, the code itself works fine just want to change how it is displayed in Explorer,
Code:
<
$expiredate = "$year-$month-$day";
$expiretime = "$hour:$min";

$exptime = explode(":",$expiretime);
$expdate = explode("-",$expiredate);
$expiretimestamp = mktime($exptime[0],$exptime[1],0,$expdate[1],$expdate[2],$expdate
[0],-1);
$seconds_left = $expiretimestamp - time();

$countdown = ($seconds_left >= 0) ? true : false;
>

<script language="JavaScript">
<!--
function showtime() {        
setTimeout("showtime();",1000);
sourcedate.setTime(sourcedate.getTime()-1000);
var hh = (sourcedate.getDate()-1)*24 - 9 + sourcedate.getHours()-1;
if ( hh < 0 ) {
document.all["clock"].innerText = '';
this.location.href = this.location.href;
}
var mm = sourcedate.getMinutes();
var ss = sourcedate.getSeconds();
if (hh >= 0) {
document.all["clock"].innerText = ((hh < 10) ? "0" : "") + hh + ((mm < 
10) ? ":0" : ":") + 
mm + ((ss < 10) ? ":0" : ":") + ss;
}
}

sourcedate = new Date(<?= date("Y,m,d,H,i,s",$seconds_left);?>);
//-->
</script>

<font color="black" size="2" face="Times New Roman, Times, serif">Time Remaining: </font><font color="red" size="2" face="Times New Roman, Times, serif">
<span name="clock" id="clock" class="top_tbl">Countdown 
                      here</span> Seconds</font>
<script language="JavaScript">
<!--
showtime();
//-->
</script>

Reply With Quote
  #2  
Old March 16th, 2008, 06:34 AM
NetSurfer NetSurfer is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 82 NetSurfer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 16 h 33 m 9 sec
Reputation Power: 0
Just change the code that sets innerText value to this:
Code:
if (hh >= 0) {
document.all["clock"].innerText = hh + " Hours " + mm + " Minutes " + ss + " Seconds";
}

Output should be like this: 4Hours 32 Minutes 35 Seconds

Reply With Quote
  #3  
Old March 16th, 2008, 07:09 AM
footballer footballer is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 73 footballer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 h 51 m 55 sec
Reputation Power: 1
This did not change my countdown format, still displays format 00:00:00 Seconds

Reply With Quote
  #4  
Old March 16th, 2008, 07:12 AM
footballer footballer is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 73 footballer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 h 51 m 55 sec
Reputation Power: 1
I should have mentioned that the Count Down time is set in the HTML as well, here it is,

Code:
$expiredate = "2008-12-22";
$expiretime = "10:46";
$exptime = explode(":",$expiretime);
$expdate = explode("-",$expiredate);
$expiretimestamp = mktime($exptime[0],$exptime[1],0,$expdate[1],$expdate[2],$expdate
[0],-1);
$seconds_left = $expiretimestamp - time();

Reply With Quote
  #5  
Old March 16th, 2008, 07:30 AM
NetSurfer NetSurfer is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jul 2007
Posts: 82 NetSurfer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 16 h 33 m 9 sec
Reputation Power: 0
This HTML page displays time in the format you need. Play with it.
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
<script language="JavaScript">
<!--
function showtime() {        
 setTimeout("showtime();",1000);
 sourcedate.setTime(sourcedate.getTime()-1000);
 var hh = (sourcedate.getDate()-1)*24 - 9 + sourcedate.getHours()-1;
 if ( hh < 0 ) {
  document.getElementById("clock").innerHTML = '';
  this.location.href = this.location.href;
 }
 var mm = sourcedate.getMinutes();
 var ss = sourcedate.getSeconds();
 if (hh >= 0) {
  document.getElementById("clock").innerHTML = hh + " Hours " + mm + " Minutes " + ss + " Seconds";
 }
}

sourcedate = new Date();
//-->
</script>
</head>
<body>

<font color="black" size="2" face="Times New Roman, Times, serif">Time Remaining: </font><font color="red" size="2" face="Times New Roman, Times, serif">
<span name="clock" id="clock" class="top_tbl">Countdown 
                      here</span> Seconds</font>

<script language="JavaScript">
<!--
showtime();
//-->
</script>

</body>
</html>


I used document.getElementById("clock") 'caz it's a crossbrowser way to get some element by its identifier. Also i replaced innerText by innerHTML - not all browsers implement innerText property

Reply With Quote
  #6  
Old March 20th, 2008, 08:49 AM
footballer footballer is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 73 footballer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 h 51 m 55 sec
Reputation Power: 1
This doesn't display the days which is really what I am after sorry,

Reply With Quote
  #7  
Old March 21st, 2008, 06:31 AM
footballer footballer is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Feb 2008
Posts: 73 footballer User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 18 h 51 m 55 sec
Reputation Power: 1
Any one able to help me display the Days as well as hours, minutes and seconds remaining?

Thanx in advanced

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesClient Side Things > Need help with to change Javascript Count Down


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway