The "Freeola Customer Forum" forum, which includes Retro Game Reviews, has been archived and is now read-only. You cannot post here or create a new thread or review on this forum.
This is the function which gets the time (some spaces added to get over the 50char post limit):
function displaytime(){
serverdate.setSeconds(serverdate.getSeconds()+1)
var daystring=dayarray[serverdate.getDay()];
var datestring=daystring+", "+montharray[serverdate.getMonth()]+" "+padlength(serverdate.getDate())+", "+serverdate.getFullYear();
var timestring=padlength(serverdate.getHours())+":" +padlength(serverdate.getMinutes())+ ":"+padlength(serverdate.getSeconds())
document.getElementById ("servertime").innerHTML=datestring+" "+timestring
}
I've checked and double checked the coding but it looks identical to the page b.c. (before crash). Is there a global variable/permission which needs to be switched [back?] on to allow the return of the sever time upon request?
Failing this - does anyone have a good script to do this? It must be the server time and not the local pc time.
thanks
JTD
Luke wrote:
> 1) It tends to be bad practice to use setInterval().
>
> 2) It fills up the JS/Browser Window thread with something not
> so useful.
I'm more of a data and PHP person than a javascript coder. Which is why, as I said in a previous post, the actual code is not mine - it just looked neat and did what I wanted.
> It's a nice experiment and not massively resource heavy, I was
> just saying what function does it actually have when my computer
> tells me the time? I know it's the server time, but you could
> just change the timezone of the local time to match server time.
The reason I need to display the server time and not the local PC time is because I set a deadline for the submission of form data.
When a certain page on my site is loaded then I do a quick server timecheck and the result of 'has the deadline passed?' is conveyed to the member by use of a graphic.
To remove any room for arguments and to prevent cheating by changing the date/time of the pc I use the server time. I could just as well use a UTC server but I actually thought it would be more efficient by using the local server and not query another web site.
> 3) I'm just a weirdo who is particular about random things.
I'm sorry to hear that - have you thought about getting it seen to?
JTD
And Eccles, I know it simply increments every second rather than using XHR but:
1) It tends to be bad practice to use setInterval().
2) It fills up the JS/Browser Window thread with something not so useful.
3) I'm just a weirdo who is particular about random things.
I'm still interested in having something which displays a self updating time but i'll maybe look at other options.
Thanks to all for your comments.
JTD
JimTheDog: does Firebug throw up any errors (or the Javascript console for whatever browser you are using). Seems like it's either a syntax problem or something else on the page is interfering, hard to tell without seeing the page!
On my site, members have to submit a form by a certain deadline and I like to have a clock to show the server time rather than there be arguments over what the deadline was when they clicked submit.
You might also want to change the title of this thread to 'dodgy coder problem'.
JTD
Good point - yes it is being parsed:
extract of source view:
var dayarray=new Array("Sunday","Monday","Tuesday ","Wednesday ","Thursday ","Friday","Saturday")
var currenttime ='Friday, July 2, 2010 15:00:21'
var montharray=new Array("January","February ","March","April","May ","June ","July","August","September","October ","November","December")
var serverdate=new Date(currenttime)
.. it's not the server then.
I'm sure the page hasn't changed but I'll have to review my tags - it gets very confusing when you include other pages.
JTD
I gave the phpinfo on freeolaweb a quick once over yesterday but didn't compare it to another webserver as I came to a (possibly incorrect) conclusion that it wasn't a PHP issue.
I also didn't try the script in it's own file - though I'm not sure why it would make a difference.
I'll do some more tests tonight and feedback results.
JTD