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
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

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

  • 14-01-2006 9:12pm
    #1
    Registered Users, Registered Users 2 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, Registered Users 2 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, Registered Users 2 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