Click to See Complete Forum and Search --> : Displaying a time different to system time
JavaHead Jonnie
11-03-2003, 10:06 AM
I want to display a time that is different to the user's system time or GMT etc. You see I'm making an MMORPG and on the game's website I want to diplay the ingame time. For instance - time in the game is the same as GMT when I start it, but time passes two times as fast as in reality. I know this is possible because I've seen it before, but I'm not sure if it was javascript or not. Please can someone help me?
Thanks :)
JavaScript is client-side, so it can only display the system time of the user browsing the site, not the time of the server or game located on the server; so you will need to use whatever server-side language exists to set the start time dynamically (assuming there is a clock that changes by second or minute without reloading the page).
[J]ona
JavaHead Jonnie
11-03-2003, 12:20 PM
Alright, thanks anyway. I'm OK at PHP so i'll try that.
http://php.net/date
[J]ona
halifaxrick
11-03-2003, 01:21 PM
Would you be able to do it in java script if you knew when the games started?
Calculate the elapsed time, and then double it and add it onto the start time?
Originally posted by halifaxrick
Would you be able to do it in java script if you knew when the games started?
Calculate the elapsed time, and then double it and add it onto the start time?
Yes, you could probably mathematically calculate it if you knew the time at which the game started, but you must also know what time it is on the server, so you would need the time you mentioned and the time of the game currently put into the Javascript code by a server-side language (apparently PHP in this case).
[J]ona
halifaxrick
11-03-2003, 01:36 PM
Cool thanks, what I was thinking would only work if everyone was int the same timezone (and had their clocks set correctly).