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 3 of 3
  1. #1
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts

    Shops open/closed

    Hey.

    I have a market with different shops, where people can buy stuff at. But I want to make it more realistic, so the shop opens at 7 AM in the morning and closes at 9:59 PM.

    I tried playing around with the date(); function but couldn't get it to work. Can anyone help me to check if the time is between 7:00 AM and 9:59 PM?
    ( date("G:i"); )

    Thanks
    Last edited by [vengeance]; 09-08-2009 at 12:16 AM.

  • #2
    Regular Coder Zangeel's Avatar
    Join Date
    Oct 2007
    Location
    public_html/
    Posts
    638
    Thanks
    17
    Thanked 79 Times in 79 Posts
    PHP Code:
    <?php

    if (date("G") > && date("G") < 22)
    {
        echo 
    'We\'re open for binness';
    } else {
        
        die ( 
    'We Closed :(' );
    }
    ?>
    "G" is the 24 hour time stamp for the hour interval. So the above code makes sure it's greater than 8 o clock but less than 10 o clock.
    PHP Code:
    $aString is_string((string)array()) ? true false// true :D 
    [/CENTER]

  • Users who have thanked Zangeel for this post:

    [vengeance] (09-08-2009)

  • #3
    Regular Coder
    Join Date
    Aug 2009
    Posts
    131
    Thanks
    28
    Thanked 7 Times in 7 Posts
    Quote Originally Posted by Zangeel View Post
    PHP Code:
    <?php

    if (date("G") > && date("G") < 22)
    {
        echo 
    'We\'re open for binness';
    } else {
        
        die ( 
    'We Closed :(' );
    }
    ?>
    "G" is the 24 hour time stamp for the hour interval. So the above code makes sure it's greater than 8 o clock but less than 10 o clock.
    Oh damn. I'm horrible at those "greater than" and "less than".

    I played around with

    PHP Code:
    date("Gi") > 700 
    etc. No wonder why it didn't work, lol. Thanks for your help.


  •  

    Posting Permissions

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