GetDotted Domains

Viewing Thread:
"Web Server (8) time return problem"

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.

Thu 01/07/10 at 20:22
Regular
"Ctrl, Alt, Woof"
Posts: 212
Since the rebuild of my site after the crash and burn of freeola webserver 8 a few weeks ago, my java script to display the server time has stopped working.

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
Sun 04/07/10 at 18:14
Regular
"Ctrl, Alt, Woof"
Posts: 212
Hi Luke,


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
Sat 03/07/10 at 12:43
Regular
"Embrace the Martian"
Posts: 285
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.

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.
Sat 03/07/10 at 08:45
Regular
"Ctrl, Alt, Woof"
Posts: 212
I've removed it for now - I'll revisit it when I have more time.

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
Sat 03/07/10 at 00:10
Staff Moderator
"Aargh! Broken..."
Posts: 1,408
Check the code again Luke, it only gets the time from the server on page load, not each time the function is run. Something like this would be overkill but even more accurate.

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!
Fri 02/07/10 at 20:37
Regular
"Devil in disguise"
Posts: 3,151
Its a client side bit of javascript updating the time every second. Its not the most elegant solution but hardly resource heavy I think.
Fri 02/07/10 at 19:27
Regular
"Ctrl, Alt, Woof"
Posts: 212
If it's causing you problems or you/freeola would just rather I didn't do it then I can let it go - it would save me having to fix it I suppose.

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
Fri 02/07/10 at 15:34
Regular
"Embrace the Martian"
Posts: 285
It's pretty resource heavy and over time, inaccurate to display times in a ticking fashion like this. You sure you even need this functionality?
Fri 02/07/10 at 15:07
Regular
"Ctrl, Alt, Woof"
Posts: 212
Garin,

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
Fri 02/07/10 at 13:08
Regular
"Devil in disguise"
Posts: 3,151
Is the PHP being parsed or not? If it is being parsed, what is it assigning to currenttime.
Fri 02/07/10 at 12:54
Regular
"Ctrl, Alt, Woof"
Posts: 212
Thanks Hmmm... that is interesting.

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

Freeola & GetDotted are rated 5 Stars

Check out some of our customer reviews below:

Unrivalled services
Freeola has to be one of, if not the best, ISP around as the services they offer seem unrivalled.
Many thanks!
You were 100% right - great support!

View More Reviews

Need some help? Give us a call on 01376 55 60 60

Go to Support Centre
Feedback Close Feedback

It appears you are using an old browser, as such, some parts of the Freeola and Getdotted site will not work as intended. Using the latest version of your browser, or another browser such as Google Chrome, Mozilla Firefox, or Opera will provide a better, safer browsing experience for you.