> -----Original Message----- > From: Paul M Foster [mailto:paulf@xxxxxxxxxxxxxxxxx] > Sent: Tuesday, October 19, 2010 7:37 AM > To: php-general@xxxxxxxxxxxxx > Subject: Re: Firs Day Of Week UNIX > > On Tue, Oct 19, 2010 at 07:00:55AM -0700, Don Wieland wrote: > > > Hi gang, > > > > I need a bailout. > > > > I have a fields called "sys_first_day_of_week" and the user can select > > one value which will be from a menu with these options: > > > > Monday > > Tuesday > > Wednesday > > Thursday > > Friday > > Saturday > > Sunday > > > > Based on this "Preference" and TODAYS DATE, I want to calculate the > > first day of the week. > > > > So if my preference is "Monday" and Today's date is 10/19/2010, I want > > to return a value of: 1287374400 (which is 10/18/2010) > > > > if my preference is "Wednesday" and Today's date is 10/19/2010, I want > > to return a value of: 1286942400 (which is 10/13/2010) > > > > Appreciate any help. > > I would strongly suggest you use a date class which uses julian days > internally to represent dates. This makes date calculations vastly more > simple and accurate than using seconds to do the calculation. I have a date > class I'll send you, if you like. > > Just get today's date, and today's day of the week. Then just add or subtract > days to get the other dates needed. In fact, the date class I mentioned has > two functions, begwk() and endwk() which allows you to return the > beginning or ending of the week, based on today's date and a user- > configurable end-of-week day. > > Paul > > -- > Paul M. Foster > Date class with methods begwk() & endwk()? Is that from PEAR/PECL? I don't see it in the manual. I do see getDate() [1]; <?php $today = getdate(); print_r($today); ?> Array ( [seconds] => 40 [minutes] => 58 [hours] => 21 [mday] => 17 [wday] => 2 [mon] => 6 [year] => 2003 [yday] => 167 [weekday] => Tuesday [month] => June [0] => 1055901520 ) This would get you going. Regards, Tommy [1] http://us.php.net/manual/en/function.getdate.php -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php