Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6

Thread: Time Problem

  1. #1
    Regular Coder
    Join Date
    Jul 2003
    Location
    Singapore
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Question Time Problem

    hi,
    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.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Eh?
    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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 

  • #3
    Regular Coder
    Join Date
    Jul 2003
    Location
    Singapore
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts
    thanks.
    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?

  • #4
    Senior Coder NancyJ's Avatar
    Join Date
    Feb 2005
    Location
    Bradford, UK
    Posts
    3,172
    Thanks
    19
    Thanked 65 Times in 64 Posts
    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.

  • #5
    Regular Coder
    Join Date
    Jul 2003
    Location
    Singapore
    Posts
    130
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Thumbs up

    Thanks very much!

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    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.
    PHP Code:
    header('HTTP/1.1 420 Enhance Your Calm'); 


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •