-2

How can I calculate Next Business Day given a Zend_Date and a cutoff time of 5pm? Business days are M-F (weekdays).

Example: Fri 4 pm should return same date Sat anytime should return next Mon Tue 8 pm should return Wed

gandalf007
  • 87
  • 7
  • possible duplicate of [Next business day of given date in PHP](http://stackoverflow.com/questions/5532002/next-business-day-of-given-date-in-php) – Dan Blows Jun 08 '12 at 16:47
  • I know how I'd do it in PHP with adding days to time() but there has to be a better way – gandalf007 Jun 08 '12 at 16:47
  • @gandalf007 Why must there? What's wrong with that approach? – Dan Blows Jun 08 '12 at 16:48
  • @Blowski yes I just saw that, didn't know how to translate that from/to Zend_Date – gandalf007 Jun 08 '12 at 16:49
  • Will you need to exclude holidays? – Eugene M Jun 08 '12 at 16:51
  • @gandalf007 Welcome to StackOverflow. If you can show us the specific problem that you're having, we'll help you to fix it. At the moment, your question reads a little bit like "please write the following code for me". There's no context of why you need to do this, what you've already tried, and why the other related questions do not solve your problem. – Dan Blows Jun 08 '12 at 16:55

1 Answers1

2

I think this has been asked before, Next business day of given date in PHP, but here it is using Zend_Date:

$now = new Zend_Date();
if (($now->get(Zend_Date::WEEKDAY_DIGIT) % 6 == 0)
 || ($now->isLater('17:00:00', Zend_Date::TIMES))
) { 
    $now->set(
        strtotime('+1 weekday', $now->toString(Zend_Date::TIMESTAMP)),
        Zend_Date::TIMESTAMP
    );
}   
echo $now->toString(Zend_Date::W3C);
Community
  • 1
  • 1
nachito
  • 6,975
  • 2
  • 25
  • 44