Time [Please Read](Solved)

Location of the Videos
Post Reply
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Time [Please Read](Solved)

Post by vitinho444 »

Hey Guys!!

So im here to ask you guys how can i make a "server time" function!

Well, i know that there's a lot of questions around this but what i was looking for its to make a function that uses a special GMT (i will choose which one later) but well, i want the function to "include" this special GMT so players cant just change their Computer's time ...

so basicly this is :

GMT (it can be stored in a website, that ones that show's you the hours) >>>>> my game >>>> then the server can call it anytime and it keep's counting and counting...

PS: i dont need date.

Thanks a lot guys!
Last edited by vitinho444 on Tue Jun 07, 2011 1:21 pm, edited 1 time in total.
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
Chromeozone
Posts: 294
Joined: Sat Apr 09, 2011 1:21 pm

Re: Time [Please Read]

Post by Chromeozone »

vitinho444 wrote:Hey Guys!!

So im here to ask you guys how can i make a "server time" function!

Well, i know that there's a lot of questions around this but what i was looking for its to make a function that uses a special GMT (i will choose which one later) but well, i want the function to "include" this special GMT so players cant just change their Computer's time ...

so basicly this is :

GMT (it can be stored in a website, that ones that show's you the hours) >>>>> my game >>>> then the server can call it anytime and it keep's counting and counting...

PS: i dont need date.

Thanks a lot guys!

Sorry, what excaclty are you asking for? say the question fully. because you go onto "this special GMT so players cant just change their Computer's time" then server stuff?
Image
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Time [Please Read]

Post by Jackolantern »

I am not clear on the question, either. Remember that with PHP, the only clock that is of any importance is the web server clock, and your users will have no access to change that. Therefore, there is no need to create a custom clock in PHP since the web server's internal clock will work much better. For client-side scripts, you could perhaps do an AJAX call to get the real time from the server.

In both cases you can adjust to whatever GMT offset you need in code.
The indelible lord of tl;dr
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: Time [Please Read]

Post by Callan S. »

It sounds like you just want

Code: Select all

$currenttime = time();
That'll give you the time on the server, in seconds, since some time in the 1970's.

I remember asking a question like this a few months ago :)
Fight Cycle : My latest Browser game WIP
Driftwurld : My Browser Game WIP
Philosopher Gamer : My Blog
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: Time [Please Read]

Post by vitinho444 »

O.O

so what you are saying is that if i use
$currenttime = time();
it will use my host time and not the players computer time?

if yes then forget the question and thanks..


PS:

The main question is:
How to make a clock system that in any situation cant be changed by a player (and keeps counting xD)
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Time [Please Read]

Post by Jackolantern »

Thats right! PHP has no access at all to the player's computer clock. It will use the web server clock every time, and the player has no way to change it.
The indelible lord of tl;dr
Chromeozone
Posts: 294
Joined: Sat Apr 09, 2011 1:21 pm

Re: Time [Please Read]

Post by Chromeozone »

Unless by hacking into the server:)
Jackolantern wrote:Thats right! PHP has no access at all to the player's computer clock. It will use the web server clock every time, and the player has no way to change it.
Image
User avatar
Jackolantern
Posts: 10891
Joined: Wed Jul 01, 2009 11:00 pm

Re: Time [Please Read]

Post by Jackolantern »

True! But in that case you have a lot more to worry about than the clock :lol:

Code: Select all

user->gold += 999999999999;
The indelible lord of tl;dr
User avatar
Callan S.
Posts: 2042
Joined: Sun Jan 24, 2010 5:43 am

Re: Time [Please Read]

Post by Callan S. »

vitinho444 wrote:O.O

so what you are saying is that if i use
$currenttime = time();
it will use my host time and not the players computer time?

if yes then forget the question and thanks..
Yes, that's right (as Jack said as well). It's good, isn't it? :D

If this is resolved, could you edit your subject title to have [Resolved] at the end of it, as that'll help out other people looking up this subject in future :)
User avatar
vitinho444
Posts: 2819
Joined: Mon Mar 21, 2011 4:54 pm

Re: Time [Please Read]

Post by vitinho444 »

well thanks

but i need a HH:MM:SS

HH: Hour
MM: Minutes
SS: Seconds

how can i make:

Code: Select all

$currenttime = time();
to give me Hours and minutes and seconds xD
My Company Website: http://www.oryzhon.com

Skype: vpegas1234
Post Reply

Return to “Older Browser MMO Videos”