Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

PHP, if date() is between ......

Options
  • 14-01-2006 10:12pm
    #1
    Registered Users Posts: 673 ✭✭✭


    Hey,

    Im trying to write an if statement that will run if the date is for example any monday between 10:00 and 14:00.

    How would i go about this? How do i compare the current date() with a date set in a variable?

    Thanks


Comments

  • Registered Users Posts: 19,396 ✭✭✭✭Karoma


    Use getdate() -> This will return an array containg the date and
    time.. You can then check against the array data..


  • Closed Accounts Posts: 7,145 ✭✭✭DonkeyStyle \o/


    <?php
      if (date('l') == "Monday" & date('G') >= 10 & date('G') <= 14)
      {
         echo "Do stuff";
      }
    ?>
    
    Seems to work...
    Looky here for specific arguments to the date function >> http://ie.php.net/date


  • Registered Users Posts: 673 ✭✭✭Bananna man


    <?php
      if (date('l') == "Monday" & date('G') >= 10 & date('G') <= 14)
      {
         echo "Do stuff";
      }
    ?>
    
    Seems to work...
    Looky here for specific arguments to the date function >> http://ie.php.net/date


    Nice one, thats got it sorted!!


Advertisement