J
Julia Briggs
Hello, below is a popular Javsscript on-screen count up display, and
in this case what is happening is its pulling the system time/date
from the local computer and displaying the difference from the
starting time, which in this case is a fixed time pulled off the
server (using PHP as you can see below).
What I want it to do is pull a fixed time off the server and replace
it with the JavaScript version in this script. The problem I'm having
is that I want to be able to execute this script with a default Zero
time starting point, and since this script was crafted to pull the
computer time, it's getting all bogged up with timezone adjustments
--- so I can handle that part using PHP, as long as I have a way to
plug the date values in somehow using a similar method as I'm using
for the PHP start date below (i've added extra whitespace around the
PHP starting point time).
Any ideas? Help would be very much appreciated at this point in time
(no pun intended) as I'm about to pull out my hair!!!
<<<<So, I need something like this added to flow into the code and
work. Maybe any better ideas how to slip these values in without
worrying about efficiencies?>>>>
settimenow(<?php print $yearnow ?>,<?php print $monthnow ?>,<?php
print $daynow ?>,<?php print $hournow ?>,<?php print $minutenow
?>,<?php print $secondnow ?>)
<script language="JavaScript1.2">
var displaymessage="Total Time Difference: "
var countupwidth='95%'
var countupheight='20px' //applicable only in NS4
var countupbgcolor=''
var opentags='<font face="Verdana" style="font: 10px Verdana;color:
#2B2B2B" ><small>'
var closetags='</small></font>'
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var crosscount=''
function start_countup(){
if (document.layers)
document.countupnsmain.visibility="show"
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById("countupie")
: countupie
countup()
}
if (document.all||document.getElementById)
document.write('<span id="countupie" style="width:'+countupwidth+';
background-color:'+countupbgcolor+'"></span>')
window.onload=start_countup
function setcountup(theyear,themonth,theday,thehour,theminute,thesecond){
yr=theyear;mo=themonth;da=theday;hr=thehour;mn=theminute;ts=thesecond;
}
setcountup(<?php print $startyear ?>,<?php print $startmonth ?>,<?php
print $startday ?>,<?php print $starthour ?>,<?php print $startminute
?>,<?php print $startsecond ?>)
function countup(){
var today=new Date()
var todayy=today.getYear()
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
paststring=montharray[mo-1]+" "+da+", "+yr+" "+hr+":"+mn+":"+ts
dd=Date.parse(todaystring)- Date.parse(paststring)
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 (document.layers){
document.countupnsmain.document.countupnssub.document.write(opentags+dday+
" days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds
"+displaymessage+closetags)
document.countupnsmain.document.countupnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+displaymessage+dday+ " days, "+dhour+"
hours, "+dmin+" minutes, and "+dsec+" seconds "+closetags
setTimeout("countup()",1000)
}
</script>
<ilayer id="countupnsmain" width=&{countupwidth};
height=&{countupheight}; bgColor=&{countupbgcolor};
visibility=hide><layer id="countupnssub" width=&{countupwidth};
height=&{countupheight}; left=0 top=0></layer></ilayer>
</div>
in this case what is happening is its pulling the system time/date
from the local computer and displaying the difference from the
starting time, which in this case is a fixed time pulled off the
server (using PHP as you can see below).
What I want it to do is pull a fixed time off the server and replace
it with the JavaScript version in this script. The problem I'm having
is that I want to be able to execute this script with a default Zero
time starting point, and since this script was crafted to pull the
computer time, it's getting all bogged up with timezone adjustments
--- so I can handle that part using PHP, as long as I have a way to
plug the date values in somehow using a similar method as I'm using
for the PHP start date below (i've added extra whitespace around the
PHP starting point time).
Any ideas? Help would be very much appreciated at this point in time
(no pun intended) as I'm about to pull out my hair!!!
<<<<So, I need something like this added to flow into the code and
work. Maybe any better ideas how to slip these values in without
worrying about efficiencies?>>>>
settimenow(<?php print $yearnow ?>,<?php print $monthnow ?>,<?php
print $daynow ?>,<?php print $hournow ?>,<?php print $minutenow
?>,<?php print $secondnow ?>)
<script language="JavaScript1.2">
var displaymessage="Total Time Difference: "
var countupwidth='95%'
var countupheight='20px' //applicable only in NS4
var countupbgcolor=''
var opentags='<font face="Verdana" style="font: 10px Verdana;color:
#2B2B2B" ><small>'
var closetags='</small></font>'
var montharray=new Array("Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec")
var crosscount=''
function start_countup(){
if (document.layers)
document.countupnsmain.visibility="show"
else if (document.all||document.getElementById)
crosscount=document.getElementById&&!document.all?document.getElementById("countupie")
: countupie
countup()
}
if (document.all||document.getElementById)
document.write('<span id="countupie" style="width:'+countupwidth+';
background-color:'+countupbgcolor+'"></span>')
window.onload=start_countup
function setcountup(theyear,themonth,theday,thehour,theminute,thesecond){
yr=theyear;mo=themonth;da=theday;hr=thehour;mn=theminute;ts=thesecond;
}
setcountup(<?php print $startyear ?>,<?php print $startmonth ?>,<?php
print $startday ?>,<?php print $starthour ?>,<?php print $startminute
?>,<?php print $startsecond ?>)
function countup(){
var today=new Date()
var todayy=today.getYear()
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
paststring=montharray[mo-1]+" "+da+", "+yr+" "+hr+":"+mn+":"+ts
dd=Date.parse(todaystring)- Date.parse(paststring)
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 (document.layers){
document.countupnsmain.document.countupnssub.document.write(opentags+dday+
" days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds
"+displaymessage+closetags)
document.countupnsmain.document.countupnssub.document.close()
}
else if (document.all||document.getElementById)
crosscount.innerHTML=opentags+displaymessage+dday+ " days, "+dhour+"
hours, "+dmin+" minutes, and "+dsec+" seconds "+closetags
setTimeout("countup()",1000)
}
</script>
<ilayer id="countupnsmain" width=&{countupwidth};
height=&{countupheight}; bgColor=&{countupbgcolor};
visibility=hide><layer id="countupnssub" width=&{countupwidth};
height=&{countupheight}; left=0 top=0></layer></ilayer>
</div>