TP-Docs
HTML5 Icon HTML5 Icon HTML5 Icon
TP on Social Media

Recent

Welcome to TinyPortal. Please login or sign up.

Members
  • Total Members: 3,963
  • Latest: BiZaJe
Stats
  • Total Posts: 195,917
  • Total Topics: 21,308
  • Online today: 884
  • Online ever: 8,223 (February 19, 2025, 04:35:35 AM)
Users Online
  • Users: 1
  • Guests: 211
  • Total: 212
  • @rjen

Countdown Block

Started by Xarcell, November 17, 2005, 04:42:32 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

JPDeni

Let me know what happens on Wednesday morning before 7am, if anybody's awake then. :)

sburke930

I was just looking at it and it seems to be an hour fast.  Is there a quick fix for that?

(My server is located in the one state that does not observe daylight savings time.)

JPDeni

Work with the line


$target = mktime(23,0,0,$mon,$day,$year);


Try changing the 23 to 22. If you're suddenly two hours off, go the other way and try 24.

sburke930


insanemustang

Quote from: PowerPyx on December 09, 2006, 04:29:17 PM

I'm using the following one (scriptbox) and to update it takes 15 secs... not more.

to reset the date you just have to change the date in STEP 1


<script language="JavaScript1.2">

/*
Dynamic countdown Script- Ã,Å  Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and TOS,
visit http://www.dynamicdrive.com
*/


function setcountdown(theyear,themonth,theday){
yr=theyear;mo=themonth;da=theday
}

//////////CONFIGURE THE COUNTDOWN SCRIPT HERE//////////////////

//STEP 1: Configure the countdown-to date, in the format year, month, day:
setcountdown(2006,12,24)

//STEP 2: Change the two text below to reflect the occasion, and message to display on that occasion, respectively
var occasion="Weihnachten!"
var message_on_occasion="Frohes Fest euch allen!"

//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countdown area
var countdownwidth='360px'
var countdownheight='20px'
var countdownbgcolor=''
var opentags='<font face="Verdana"><center>'
var closetags='</font></center>'

//////////DO NOT EDIT PASS THIS LINE//////////////////

var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var crosscount=''

function start_countdown(){
if (document.layers)
document.countdownnsmain.visibility="show"
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById("countdownie") : countdownie
countdown()
}

if (document.all||document.getElementById)
document.write('<span id="countdownie" style="width:'+countdownwidth+'; background-color:'+countdownbgcolor+'"></span>')

window.onload=start_countdown


function countdown(){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
futurestring=montharray[mo-1]+" "+da+", "+yr
dd=Date.parse(futurestring)-Date.parse(todaystring)
dday=Math.floor(dd/(60*60*1000*24)*1)
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
//if on day of occasion
if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1&&todayd==da){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+message_on_occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+message_on_occasion+closetags
return
}
//if passed day of occasion
else if (dday<=-1){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+"Occasion already passed! "+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+"Occasion already passed! "+closetags
return
}
//else, if not yet
else{
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags
}
setTimeout("countdown()",1000)
}
</script>

<ilayer id="countdownnsmain" width=&{countdownwidth}; height=&{countdownheight}; bgColor=&{countdownbgcolor}; visibility=hide><layer id="countdownnssub" width=&{countdownwidth}; height=&{countdownheight}; left=0 top=0></layer></ilayer>




Demo on : http://rad.hrsv.de/forum/index.php


Pyx

I can only get this code to show up if it's a rightside block.  As soon as I move it to the middle, or the left side, it will not show the countdown.

tick

Quote from: JPDeni on December 10, 2006, 03:40:22 AM
Try this:

$dayofweek = 'Tuesday';
if (date('l') <> $dayofweek )
{
  $mon = date('n',strtotime('next '.$dayofweek));
  $day = date('j',strtotime('next '.$dayofweek));
  $year = date('Y',strtotime('next '.$dayofweek));
}
else
{
  $mon = date('n');
  $day = date('j');
  $year = date('Y');
}
$target = mktime(23,0,0,$mon,$day,$year);
$difference = $target - time();
if ($difference > 604800)
  $difference -= 604800;
if ($difference > 576000 or $difference < 0) 
{
  echo 'Whatever you want to say between the closing of one challenge and the beginning of the next';
}
else
{
  $days = floor($difference/(24*60*60));
  $difference -= $days * 24 * 60 * 60;
  $hours = floor($difference / (60 * 60));
  $difference -= $hours * 60 * 60;
  $minutes = floor($difference / 60);
  echo $days . ' days ' . $hours . ' hours ' . $minutes . ' minutes left for the current challenge';
}


Where at  in this code do I edit for the start time and finish time. 

tick

Quote from: PowerPyx on December 09, 2006, 04:29:17 PM

I'm using the following one (scriptbox) and to update it takes 15 secs... not more.

to reset the date you just have to change the date in STEP 1


<script language="JavaScript1.2">

/*
Dynamic countdown Script- Ã...  Dynamic Drive (www.dynamicdrive.com)
For full source code, 100's more DHTML scripts, and TOS,
visit http://www.dynamicdrive.com
*/


function setcountdown(theyear,themonth,theday){
yr=theyear;mo=themonth;da=theday
}

//////////CONFIGURE THE COUNTDOWN SCRIPT HERE//////////////////

//STEP 1: Configure the countdown-to date, in the format year, month, day:
setcountdown(2006,12,24)

//STEP 2: Change the two text below to reflect the occasion, and message to display on that occasion, respectively
var occasion="Weihnachten!"
var message_on_occasion="Frohes Fest euch allen!"

//STEP 3: Configure the below 5 variables to set the width, height, background color, and text style of the countdown area


//////////DO NOT EDIT PASS THIS LINE//////////////////

var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var crosscount=''

function start_countdown(){
if (document.layers)
document.countdownnsmain.visibility="show"
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById("countdownie") : countdownie
countdown()
}

if (document.all||document.getElementById)
document.write('<span id="countdownie" style="width:'+countdownwidth+'; background-color:'+countdownbgcolor+'"></span>')

window.onload=start_countdown


function countdown(){
var today=new Date()
var todayy=today.getYear()
if (todayy < 1000)
todayy+=1900
var todaym=today.getMonth()
var todayd=today.getDate()
var todayh=today.getHours()
var todaymin=today.getMinutes()
var todaysec=today.getSeconds()
var todaystring=montharray[todaym]+" "+todayd+", "+todayy+" "+todayh+":"+todaymin+":"+todaysec
futurestring=montharray[mo-1]+" "+da+", "+yr
dd=Date.parse(futurestring)-Date.parse(todaystring)
dday=Math.floor(dd/(60*60*1000*24)*1)
dhour=Math.floor((dd%(60*60*1000*24))/(60*60*1000)*1)
dmin=Math.floor(((dd%(60*60*1000*24))%(60*60*1000))/(60*1000)*1)
dsec=Math.floor((((dd%(60*60*1000*24))%(60*60*1000))%(60*1000))/1000*1)
//if on day of occasion
if(dday<=0&&dhour<=0&&dmin<=0&&dsec<=1&&todayd==da){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+message_on_occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+message_on_occasion+closetags
return
}
//if passed day of occasion
else if (dday<=-1){
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+"Occasion already passed! "+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+"Occasion already passed! "+closetags
return
}
//else, if not yet
else{
if (document.layers){
document.countdownnsmain.document.countdownnssub.document.write(opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags)
document.countdownnsmain.document.countdownnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+dday+ " days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds left until "+occasion+closetags
}
setTimeout("countdown()",1000)
}
</script>

<ilayer id="countdownnsmain" width=&{countdownwidth}; height=&{countdownheight}; bgColor=&{countdownbgcolor}; visibility=hide><layer id="countdownnssub" width=&{countdownwidth}; height=&{countdownheight}; left=0 top=0></layer></ilayer>




Demo on : http://rad.hrsv.de/forum/index.php


Pyx

So I decided to go with this script.  I seemed to do  more what I wanted.  I see where you can edit the font type and color .  Is this where I would add tags to change the font size to something larger?

var countdownwidth='360px'
var countdownheight='20px'
var countdownbgcolor=''
var opentags='<font face="Verdana"><center>'
var closetags='</font></center>'

GhostRider2110

I know this is an old thread, but I tried using the script PowerPyx posted from scriptbox but I have having issues with it working.

SMF 1.1.8
TP 1.0 B3
MOdified Blueskies theme

I place it in any block it does not show up.  I do have it set to show up anywhere. I can turn on the Title and/or frame and they will show up.  I have change the text color in the script as well.  No dice. Any assistance would be greatly appreciated.  I have it as a Type HTML & Javascript block.

www.usscalemasters.org


See-ya
Mitch
Mitchell Baker

GhostRider2110

One other note, this script does work under TP 0.9.8.  As can be seen on www.scalemasters.org

--Mitch
Mitchell Baker

GhostRider2110

OK, I have currently given up on trying to use a javascript block.  I guess I am not understanding how it is suppose to work since it switched from scriptbox in 0.9 to HTML & Javascript in 1.x.  If someone can point me to some tutorial or documentation that would be nice.  I did check How do I create a Javascript Block but that is not accurate... 

In the mean time I found a php script which, although is not real time, works for now...

--Mitch
Mitchell Baker

This website is proudly hosted on Crocweb Cloud Website Hosting.