On Wed, 2009-03-18 at 11:46 -0400, Bob McConnell wrote: > From: Paul M Foster > > On Tue, Mar 17, 2009 at 08:52:11PM -0700, Jason Todd Slack-Moehrle > wrote: > > > >> Hi All, > >> > >> Does anyone have code and/or advice for how to get get the current > >> week (with a passed current day, say) and what then end date is at > >> Saturday. > >> > >> So take today: Tuesday March 17, 2009 > >> > >> I want to get: > >> Sunday March 15, 2009 > >> Monday March 16, 2009 > >> Tuesday March 17, 2009 > >> Wednesday March 18, 2009 > >> Thursday March 19, 2009 > >> Friday March 20, 2009 > >> Saturday March 21, 2009 > > > > I just answered a question similar to this. You might check the > > archives. In this case, you'll need to use the getdate() function (see > > php.net/manual/en/ for details) to get the array of values for today > > (like the day of the month, month number, year, etc.). The getdate() > > function returns an array, one of whose members is 'wday', which is > the > > day of the week, starting with 0 for Sunday. Use that number to > > determine how many days to go back from today. Then use mktime() to > get > > the timestamps for each day in turn. You feed mktime() values from the > > getdate() call. Then you can use strftime() or something else to print > > out the dates in whatever format, given the timestamps you got. > > > > Be careful in feeding values to mktime(). If your week spans a > > month or year boundary, you'll need to compensate for it when giving > > mktime() month numbers, day numbers and year numbers. > > You also need to be aware that on 32 bit Unix and Linux systems the > behavior of mktime() on dates after Jan 18, 2038 is undefined. The 32 > bit counter overflows early on the 19th, so any value returned is > invalid. This is not a problem on 64 bit systems. > > We ran into this recently because Support was defining "never expire" as > Today plus 30 years. A couple of sites started reporting problems about > two months ago. But the solution doesn't even require mktime(). Cheers, Rob. -- http://www.interjinn.com Application and Templating Framework for PHP -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php