How do I get the calendar to start on Monday?

Asked

Viewed 39 times

-2

     <?php
        function linha($semana){
            echo "<tr>";

            for ($i=0; $i<=6; $i++):
                if(isset($semana[$i])):
                    echo "<td>$semana[$i]</td>";
                else:
                    echo "<td> </td>";
                endif;

            endfor;

            echo "</tr>";
        }



        function calendario(){
            $dia = 1;
            $semana = array();
            while ($dia <= 31):
                array_push($semana,$dia);

                if(count($semana)== 7) :
                    linha($semana);
                    $semana = array();
                endif;

            $dia++;

            endwhile;

            linha($semana);

        }
     ?>
      <table border="1">
            <tr>
                 <th>Dom</th>
                 <th>Seg</th>
                 <th>Ter</th>
                 <th>Qua</th>
                 <th>Quin</th>
                 <th>Sex</th>
                 <th>Sáb</th>
            </tr>
           <?php calendario() ?>
      </table> 
  • 3

    You wait until Monday and start using it, there will be no mistake. joke. details more your problem.

  • kkkk, like my day 1 only starts Sunday, and I want to change so that Day 1 is another day of the week without being Sunday...

1 answer

0

You can catch the first day of the week with date("d/m/Y H:i:s", strtotime(date("Y")."W".date("W"))); (Don’t forget to define the date_default_timezone_set()).

Browser other questions tagged

You are not signed in. Login or sign up in order to post.