Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

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

  • 14-01-2006 10: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,144 ✭✭✭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