View Full Version : Time Problem
I'm making a booking system, and is trying to forbid users from cancelling a booking after 10 pm.
But the problem is, the date feature in PHP relies on the computer timing system, so a user just has to adjust his/her computer's time settings in order to "cheat" the booking system.
Anyone knows the solution to this problem? Thanks.
09-14-2005, 10:47 AM
time and date functions in php rely on the SERVER's time, not the clients. Assuming that the user is logged into the website, you can derive the correct time from the server.
Are you referring more to a timezone differential? This can be a problem. There are functions that can make use of timezone shifts, but correctly using these without problem is tough as well. Its not reliable.
However, I don't think the timezone contains any relevance at all, at least with this. If server is at location A, with GMT timing, you can set php to check for time past 10PM; this works with multiple locations on the host as well. Its all about the time relative to that location, not to the clients timezone.
Oh, BTW it would help that I mention my conception on this as well - I'm thinking of a business like a hotel for instance, and you don't want cancellations past X time. Tell me if I'm thinking wrong on this at all.
ya, the concept is similar to hotel booking, but it's not hotel booking. You get my point right.
So am I correct to say that I can "cheat" the booking system because I'm using the server on my PC, so the time PHP is using is my computer's time?
And this won't happen if I'm using a hosting service where they have their own server?
09-14-2005, 11:16 AM
that would explain why the time changed when you changed your PC's time ;)
If I were to connect to your server and change the time on my PC it wouldnt affect your time functions, in the same way if you were to move your hosting to another machine (yours or a hosting companies) and fiddle with your PCs system time it wouldnt affect it.
09-14-2005, 03:24 PM
Yep thats right. GMT is standardized time, and all hosts should be using it as its default timezone, or at least an alteration within its php to do so. I myself live in GMT -8(+/-1 due to no daylight savings), and I defaulted my php to read as GMT. Just make sure you can easily alter it in case it becomes nessessary, such as your host is not following the GMT standardized times.
Powered by vBulletin® Version 4.2.2 Copyright © 2016 vBulletin Solutions, Inc. All rights reserved.