Re: Firs Day Of Week UNIX

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Oct 19, 2010 at 08:14:47AM -0700, Tommy Pham wrote:

> > -----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];

No, it's from PMF. (I wrote it.) ;-}

Paul

-- 
Paul M. Foster

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux