tags:

views:

29

answers:

2

All the users are in the United States. I need to be able to list all weekdays besides today. So say that it's Thursday, October 7. It should start by listing Friday, October 8 and then Monday, October 11.

I know how to make sure I'm only listing weekdays when looping through, but the trouble I have is making sure tomorrow is tomorrow. In the past it's changed at about 8:00 at night eastern time. I'm thinking I'd like to have is so when it's maybe 12:00 pacific time to count it as the next day.

A: 

You can use strtotime to get the date of the next days and you can use date to determine if a date is a week day :

<?php
$reference = time(); // We set today as the first day //

for ($i=0, $j=0; $i<5; $i++, $j++) {
   $nextDay = strtotime('+' . $j . ' days', $reference);
   if (date('w', $nextDay) > 0 && date('w', $nextDay) < 6) {
       echo date('r', $nextDay), "\n";
   } else {
       $i--;
   }
}
?>
HoLyVieR
A: 
<?php
   $current = new DateTime('now');
   $last = new DateTime('saturday');
   while ($current < $last) {
      echo $current->format('l, F j'), "\n";
      $current->modify('+1 day');
   }
?>
Evert