Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.
Hi all, please see this major site announcement: https://www.boards.ie/discussion/2058427594/boards-ie-2026

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
Advertisement