On Tue, 09 Jan 2001, jeremy brand wrote:
> why not this?
> 
> $year = date('Y');
> $month = date('m');
> $day = (int)date('d');
> 
> if ($day >= 1 && $day < 8)
>   $week = 1;
> else if ($day >= 8 && $day < 15)
>   $week = 2;
> else if ($day >= 15 && $day < 22)
>   $week = 3;
> else if ($day >= 22 && $day < 29)
>   $week = 4;
> else if ($day >= 29)
>   $week = 5;
> 
> print "$year_$month_$week";

that won't work if "week #n" is defined as that set of days in the
month that starts on Sunday (or your preferred start day) and ends on
Saturday (or ...).

i'm sure there's code out there, but i'm too lazy to look.  what i did
was hack out a terrible solution that works for me.  i open a pipe to
cal (giving it the month and year i want), read the lines (dropping the
first two lines which are header), and parse the days out.  as i said,
terrible :).  someday, i'll fix that :).  or maybe sooner, if someone
will post a clean way to do that.

tiger

-- 
Gerald Timothy Quimpo  [EMAIL PROTECTED]  http://members.xoom.com/TigerQuimpo

  entia non sunt multiplicanda     veritas liberabit vos
  praetere necessitatem            mene sakhet ur-seveh    

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]

Reply via email to