PDA

View Full Version : Countdown II Script



Anenga
09-08-2004, 07:14 PM
http://www.dynamicdrive.com/dynamicindex6/dhtmlcount2.htm

I use this script on a website to tell a user how long until they can download something (I have it where they can become a subscriber and download instantly, otherwise wait 24 hours).

Everything worked great until people started complaining that the script said they could download it, but the script wouldn't let them because their localtime didn't match the server time.

So what I did to fix this was to put...

<?
$now = time(); // GMT Time in seconds since epoc
$currTime = ($now * 1000); // Convert to milliseconds ?>

var today=new Date(<? echo $currTime; ?>)
Unfortunately, customizing the Date function seems to break the countdown script. It prints the time left until you can download etc., but it does not countdown... :( Anyone have any idea how to fix this? I don't know Javascript [well].

cr3ative
09-08-2004, 07:17 PM
You might need to change

var todaysec=

to what you want, rather than what you did.

Hope this helps
cr3ative

Anenga
09-08-2004, 07:34 PM
You might need to change

var todaysec=

to what you want, rather than what you did.

Hope this helps
cr3ative
No offense, but that doesn't really sound right...

I mean, isn't that variable based off the today function? I mean...

var today=new Date(<? echo $currDate; ?>)
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()
today.getSeconds = Local seconds of the minute (0-59), why would that make any difference? .......

ddadmin
09-08-2004, 09:32 PM
Do you have a URL to the problematic page? I'm a little rusty on converting JavaScript dates to GMT, but if the problem is just syntax wise (interface between your PHP variable and the JavaScript itself), I can quickly look over and find the problem.

Anenga
09-09-2004, 01:53 AM
Well, you'd have to sign up on the forums to be able to access the page etc. Here, perhaps just do this...

Replace: var today=new Date()

With: var today=new Date(GMTmilliseconds)

Replace GMTmilliseconds with, obviously, the current date in GMTmilliseconds. (i.e. 873991800000). Try it out, see if the script works. It doesn't for me, see if u can get it to work.