Software School Projects | Academic Students Projects | Source Codes | Tablets header
Please use our contact us form or send email to Support@srishtis.com.

How to skip days?
If we needed to start dojng something every Monday thru Thursday of the year and I needed the ability to skip Friday, Saturday and Sunday from showing up in my task list. I started thinking about how I would use PHP to tell me what days these were and skip listing Fri, Sat, Sun. I didn't really need to know what had happened in the past, just what would be happening in the future.
If today was a Fri, Sat, or Sun, then I would need to skip showing these days and go straight to the next Monday. I wanted to show a month in an advance at any one time so that I could get a little ahead in my to-do list.
function dayInfo($timestamp) {
global $pretty_date, $day_of_week, $future_count, $i;
   $pretty_date = date("D, M j, Y", $timestamp); // Saturday, May 10, 2003
   $day_of_week = date("w", $timestamp);
   switch(TRUE) {
     case $day_of_week == 1 || $day_of_week == 2 || $day_of_week == 3 || $day_of_week == 4:
       $future_count++;
       return true;
     break;
   }
$i--; // do not advance this iteration
return false;
}

$future_days = 0; // counter of days
$max_days = 24; // show 6 weeks into the future (4 days [m,tu,w,th] X 6 weeks = 24)
$now = time();
$theday = $now; // start with today

for($i=0; $i<$max_days; $i++) {
   $D = date("j", $theday);
   $M = date("g", $theday);
   $YY= date("Y", $theday);
   $timestamp = mktime(11,0,0, $M, $D, $Y); // 11 = daylight savings offset, start at noon each day
   if(dayInfo($theday)) {
       // this is a monday through thursday, so print
       print("$pretty_date ($day_of_week):<br>");
   }
$theday = $theday + 86400; // add 24 hours to clock
}
print("<br>Total days: <b>$future_count</b>");
?>
Job or extra money for students

Search Engine Rank of your blog or websites