So i found on internet this countdown script i want to use for mi site.
His functions would have to be something like this.
Every day at 01:00 and 13:00 the event will start and will last 1 hour.Durring that time instead of a countdown will display a text msg.After that it will continue the countdown as normal.
ATM i managed to make the clock be loaded in the page and show the countdown only for 1 event a day but sometimes when srv time is 22 it showing the text(dont know why)
I have never worked before with js except that i toke a script and loaded it in mi files so please be patiente with me.
Here is the code its laoded in mi page
<div id="live_time_clock_count" >
<div class="EventTime"><span class="ticker" id="tickerMSG"></span>
</div>';
?>
<script>if ($('tickerMSG')) {
TICKER.addOption('one',{
ALARM_MIN: 10,
END_HOUR: 15,
END_MIN: 0,
END_SEC: 0,
START_HOUR: 14,
START_MIN: 0,
START_SEC: 0,
INGAME_MSG: "",
WARNING_SIZE: 18,
START_MSG: "In Progress",
UNITS: 4,
msgID: "tickerMSG",
offset: 3,});
TICKER.countDown('one');
}
</script>
<?php
echo '</div>
and here is the js source
/* Ticker function for ticking clock for Nation War for Cabal page, for OGPlanet.
* coder: Seungjin Kim
* function: this will set the dates for Nation War start time, which is 6:00PM, PST.
* This script can behave in a way that it ticks on its own.
* within 10 minutes to 6:00PM, it will be in alarm mode.
* After 6PM and until end of Nation War, it will say a message, and not show time.
* After that, it will reset its mode and go to Normal mode where it will show ticking again.
*
* USAGE: TICKER.addOption('one',{START_HOUR : 18, START_MIN : 40});//sets the time, and makes a new 'option' in 'options' hash, key is 'one'
* TICKER.countDown('one'); //starts counting down.
*/
var TICKER = { options:
{
'default':{
ALARM_MIN: 10,//X minutes prior to nation war BLINK for 40 minutes before the WAR!!!
END_HOUR: 2, //End hour
END_MIN: 0, //Minute that the Nation war ends
END_SEC: 0, //Second that the Nation war ends
START_HOUR: 1, //Start hour
START_MIN: 10, //Start minute
START_SEC: 0, //Start second
INGAME_MSG: "Nation war now activated! You may join the war channel.",
WARNING_SIZE: 23,
START_MSG: "Nation war in progress. Too late to join the war channel.",
UNITS: 4,
msgID: "tickerMSG",
offset: 3,
}/*units in time. 4 = hr:min:sec:millisec */
},
addOption: function(o,obj){//any non-defined values are copied over from default.
this.options[o] = obj;
for (var i in this.options['default']){
if (this.options[o][i.toString()] == undefined) {this.options[o][i.toString()] = this.options['default'][i.toString()];}
}
},
printMSG: function(o,msg){
document.getElementById(this.options[o].msgID).innerHTML = msg;},
countDown: function(o){
if (typeof(this.options[o]) != "object") {o = "default";}//if o is wrong, set options[o] to "default".
var option = this.options[o];//simplifing.. because we call this bunch of times
var dnow = new Date();//CURRENT DATE!
/* START ADJUSTING TIME FOR TIME OF LA,CA */
var time = 1215815794000;
var offset = 3600000 * option.offset;
/*adjusting for DST - daylight savings time
var lsm = new Date; var lso = new Date;
lso.setMonth(3);//April
lso.setDate(1);//setting up to get first Sunday of April
lso.setDate(8 - lso.getDay());//got first Sunday of April.
lso.setHours(2);
lsm.setMonth(9);//October
lsm.setDate(1);//setting up to get first Sunday of April
lsm.setDate(8 - lsm.getDay());//got first Sunday of April.
lsm.setHours(2);*/
dnow.setTime((dnow.getTime() + dnow.getTimezoneOffset()*60000) + offset);//offset is for DST time.
//if (dnow > lsm || dnow <= lso) dnow.setHours(dnow.getHours()-1);//offset = offset - 3600000;//dst off
/* END ADJUSTING TIME FOR TIME OF LA,CA */
var currHour = dnow.getHours();
var currMin = dnow.getMinutes();
var currSec = dnow.getSeconds();
var currMill = dnow.getMilliseconds() % 100;
var targetDate;
var diffHour = -1;
var diffMin = -1;
var diffSec = -1;
var diffMill = -1;
var time = 100; //used for calling this function time milliseconds later.. used in last line of this function
//1. ENDTIME <-> (STARTTIME - ALARM_MIN) : just tick away..
if(currHour >= option.END_HOUR && currHour < 23 && currMin > 0 && currMin > option.END_MIN)
{ targetDate = new Date(dnow.getFullYear(), dnow.getMonth(), dnow.getDate()+1, option.START_HOUR, option.START_MIN, option.START_SEC);}
else
{ targetDate = new Date(dnow.getFullYear(), dnow.getMonth(), dnow.getDate(), option.START_HOUR, option.START_MIN, option.START_SEC); }
var diffDate = targetDate.getTime() - dnow.getTime();
diffHour = Math.floor((diffDate / (1000*60*60))%24);
diffMin = Math.floor((diffDate / (1000*60))%60);
diffSec = Math.floor((diffDate / 1000)%60);
diffMill = Math.floor((diffDate % 1000) / 11);
var diffTime =
((diffHour < 10) ? "" : "") + "<b>"+ diffHour + "</b>"+ "<span style='margin-left:40px'></span>"
+ ((diffMin < 10) ? "" : "") + "<b>"+ diffMin + "</b>"+ "<span style='margin-left:40px'></span>"
+ ((diffSec < 10) ? "" : "") + "<b>"+ diffSec + "</b>";
//+ ((diffMill < 10) ? "0" :"") + diffMill;
switch(option.UNITS){//filter out display by UNITS - hr:min:sec:millisec, AND reduce resource usage by setting revoke interval(time) via UNITS
case 3:
diffTime = diffTime.substr(0,diffTime.length-3);
time = 1000;//1 seconds
break;
case 2:
diffTime = diffTime.substr(0,diffTime.length-6);
time = 60000;//1 minute
break;
case 1:
diffTime = diffTime.substr(0,diffTime.length-9);
break;
default:
break;
}
if (diffDate < option.ALARM_MIN * 1000 * 60 && diffDate > 0)//if difference of time is within alarm range!! BLINK BLINK !!
{
time = 100;
if (dnow.getMilliseconds() % 500 > 250) {document.getElementById(option.msgID).style.fontSize = (option.WARNING_SIZE+3).toString() + 'px';}
else {document.getElementById(option.msgID).style.fontSize = (option.WARNING_SIZE).toString() + 'px';}
}
else if (diffDate < 0)
{ diffTime = option.START_MSG;}
if (option.END_HOUR < option.START_HOUR) {diffTime = "INVALID END_HOUR";}
else if (option.END_HOUR == option.START_HOUR && option.END_MIN <= option.START_MIN) {diffTime = "INVALID END_MIN";}
this.printMSG(o, diffTime);
setTimeout("TICKER.countDown('"+o+"')",time);
}
};