Note that there are some explanatory texts on larger screens.

plurals
  1. POHow I can get the pre and post dates of the week
    text
    copied!<p>Hello guys I'm building with my calendar.</p> <p>I'm trying to get the pre and post day of the current month for my calendar. Actually the calendar is already working but its not the same with the time with my laptop.</p> <p>Do I have to change something in this code?</p> <pre><code>$month = 9; $year = 2013; // calculate the number of days in the current month $day_count = cal_days_in_month(CAL_GREGORIAN, $month, $year); // get number of days for the next month $pre_days = (6 - (date('w', mktime(0, 0, 0, $month, $day_count, $year)))); // get number of days after the month $post_days = date('w', mktime(0, 0, 0, $month, 1, $year)); </code></pre> <p>Then I'm making a loop to display the dates..</p> <pre><code>echo "&lt;div id='cal_wrapper'&gt;"; echo "&lt;div class='title_bar'&gt;"; echo "&lt;div class='prev_month'&gt;&lt;/div&gt;"; echo "&lt;div class='show_month'&gt;&lt;/div&gt;"; echo "&lt;div class='next_month'&gt;&lt;/div&gt;"; echo "&lt;/div&gt;"; // end title bar echo "&lt;div class='week_days'&gt;"; foreach($weekDaysArr as $value) { echo "&lt;div class='days_of_week'&gt;".$value."&lt;/div&gt;"; } echo "&lt;div class='clear'&gt;&lt;/div&gt;"; echo "&lt;/div&gt;"; // end week days // Previous Month Filler if($pre_days != 0) { for($i = 1; $i &lt;= $pre_days; $i++) { echo "&lt;div class='non_cal_days'&gt;&lt;/div&gt;"; } } // Current day of the month filler if($day_count != 0 ) { for($x = 1; $x &lt;= $day_count; $x++) { echo "&lt;div class='cal_days'&gt;"; echo "&lt;div class='day_header'&gt;".$x."&lt;/div&gt;"; echo "&lt;/div&gt;"; } } // Current day of the month filler if($post_days != 0 ) { for($y = 1; $y &lt;= $post_days; $y++) { echo "&lt;div class='non_cal_days'&gt;&lt;/div&gt;"; } } echo "&lt;/div&gt;"; // end calendar wrapper </code></pre>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload