• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Generating week

#5
[eluser]xwero[/eluser]
This function accepts a unix timestamp an returns an array of date based on the weekday numbering used by the date function, meaning 0 as sunday and 6 as saturday.

The function can be the base of a week view.
Code:
function get_week($date)
{
   $week_days = range(0,6);
   $week_day = date('w',$date);

   foreach($week_days as $key=>$day)
   {
      if($day == $week_day)
      {
          $week_days[$key] = $date;
      }
      elseif($day < $week_day)
      {
         $week_days[$key] = strtotime('-'.$week_day+$day.' day',$date);
      }
      elseif($day > $week_day)
      {
         $week_days[$key] = strtotime('+'.$day-$week_day.' day',$date);
      }
   }
  
   return $week_days;
}


Messages In This Thread
Generating week - by El Forum - 11-30-2008, 06:03 PM
Generating week - by El Forum - 12-01-2008, 12:53 AM
Generating week - by El Forum - 12-01-2008, 01:38 AM
Generating week - by El Forum - 01-28-2009, 05:09 AM
Generating week - by El Forum - 01-28-2009, 06:23 AM
Generating week - by El Forum - 01-28-2009, 10:41 AM
Generating week - by El Forum - 01-30-2009, 03:47 AM
Generating week - by El Forum - 01-30-2009, 03:49 AM
Generating week - by El Forum - 04-24-2013, 06:09 AM
Generating week - by El Forum - 04-24-2013, 06:20 AM
Generating week - by El Forum - 04-24-2013, 06:33 AM
Generating week - by El Forum - 04-24-2013, 06:36 AM
Generating week - by El Forum - 04-24-2013, 06:50 AM
Generating week - by El Forum - 04-24-2013, 07:03 AM
Generating week - by El Forum - 04-24-2013, 07:05 AM
Generating week - by El Forum - 04-24-2013, 07:09 AM
Generating week - by El Forum - 04-24-2013, 07:11 AM

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.