Re: Firs Day Of Week UNIX
| From: | Paul M Foster | Date: | Tue, 19 Oct 2010 15:59:26 +0000 |
| Subject: | Re: Firs Day Of Week UNIX | ||
| References: | 1 2 3 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-308843@lists.php.net to get a copy of this message | ||
On Tue, Oct 19, 2010 at 08:14:47AM -0700, Tommy Pham wrote:
> > -----Original Message-----
> > From: Paul M Foster [mailto:paulf@quillandmouse.com]
> > Sent: Tuesday, October 19, 2010 7:37 AM
> > To: php-general@lists.php.net
> > Subject: Re: [PHP] 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];
No, it's from PMF. (I wrote it.) ;-}
Paul
--
Paul M. Foster