Re: week of example code

From: Date: Wed, 10 Jan 2001 04:07:23 +0000
Subject: Re: week of example code
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-33617@lists.php.net to get a copy of this message
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 tiger@kami.com http://members.xoom.com/TigerQuimpo entia non sunt multiplicanda veritas liberabit vos praetere necessitatem mene sakhet ur-seveh

« previous php.general (#33617) next »