0

I need some assistance with creating a bit of code that will check to see if I'm currently in a date/time range that is the same every week. For instance, I want to see if the current time is between Thursday 5:00pm and Monday 8:00am EVERY week.

  • 3
    Have you produced any efforts? Any code we can review? – Ohgodwhy Jul 01 '15 at 14:33
  • You'd probably want to use a cron job. – Huey Jul 01 '15 at 14:35
  • interesting? [How to check if a date is in a given range?](https://stackoverflow.com/questions/976669/how-to-check-if-a-date-is-in-a-given-range). Also: [Finding date range for current week, month and year](https://stackoverflow.com/questions/5552862/finding-date-range-for-current-week-month-and-year) – Ryan Vincent Jul 01 '15 at 14:41

1 Answers1

0
<?php    
/**
* 
* return bool
*/
 function isDateBetweenDates(DateTime $date, DateTime $startDate, DateTime $endDate) {
 return $date > $startDate && $date < $endDate;
}

to test your scenario you could call your dates against this function -- good place to start right? am containing function will have to build your weekly start and end dates to test against this.

Shane_Yo
  • 770
  • 8
  • 24