/    Sign up×
Community /Pin to ProfileBookmark

Displaying a time different to system time

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 ?

to post a comment
JavaScript

6 Comments(s)

Copy linkTweet thisAlerts:
@JonaNov 03.2003 — [font=arial][color=maroon]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).[/color][/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@JavaHead_JonnieauthorNov 03.2003 — Alright, thanks anyway. I'm OK at PHP so i'll try that.
Copy linkTweet thisAlerts:
@JonaNov 03.2003 — [font=arial] http://php.net/date [/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@halifaxrickNov 03.2003 — 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?
Copy linkTweet thisAlerts:
@JonaNov 03.2003 — [i]Originally posted by halifaxrick [/i]

[B]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? [/B]
[/QUOTE]


[font=arial][color=maroon]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 [b]currently[/b] put into the Javascript code by a server-side language (apparently PHP in this case).[/color][/font]

[b][J]ona[/b]
Copy linkTweet thisAlerts:
@halifaxrickNov 03.2003 — Cool thanks, what I was thinking would only work if everyone was int the same timezone (and had their clocks set correctly).
×

Success!

Help @JavaHead_Jonnie spread the word by sharing this article on Twitter...

Tweet This
Sign in
Forgot password?
Sign in with TwitchSign in with GithubCreate Account
about: ({
version: 0.1.9 BETA 5.15,
whats_new: community page,
up_next: more Davinci•003 tasks,
coming_soon: events calendar,
social: @webDeveloperHQ
});

legal: ({
terms: of use,
privacy: policy
});
changelog: (
version: 0.1.9,
notes: added community page

version: 0.1.8,
notes: added Davinci•003

version: 0.1.7,
notes: upvote answers to bounties

version: 0.1.6,
notes: article editor refresh
)...
recent_tips: (
tipper: @AriseFacilitySolutions09,
tipped: article
amount: 1000 SATS,

tipper: @Yussuf4331,
tipped: article
amount: 1000 SATS,

tipper: @darkwebsites540,
tipped: article
amount: 10 SATS,
)...