Connecting Tech Pros Worldwide Help | Site Map

Want to implement a PHP process in a Javascript timer

 
LinkBack Thread Tools Search this Thread
  #1  
Old July 20th, 2005, 02:31 PM
Julia Briggs
Guest
 
Posts: n/a
Default Want to implement a PHP process in a Javascript timer

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","A ug","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,theminu te,thesecond){
yr=theyear;mo=themonth;da=theday;hr=thehour;mn=the minute;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.docum ent.write(opentags+dday+
" days, "+dhour+" hours, "+dmin+" minutes, and "+dsec+" seconds
"+displaymessage+closetags)
document.countupnsmain.document.countupnssub.docum ent.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>

 

Bookmarks

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 Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Popular Articles

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 220,989 network members.