Date issues

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View

I am generating a table that is acting as a two week view of the
calendar (Sun-Sat on row 1, Sun-Sat row 2), these will then be filled
with some appointments.

I am trying to write a function that accepts a month, day, year, and
dayofweek parameters:

    function showCalendar($d, $m, $y, $dow) {

The purpose is to then figure out based on the date passed, what the
previous Sunday is.  Originally the date passed will be todays date,
but  I want to be able to generate the calendar for other dates as

Actually, as I am typing this, I can simply pass in a number of weeks
from today, starting on today.  0 for the current week, -1 for the
previous, -2 for two weeks previous, 1 for next week, 2 for two weeks
from now and use PHP date functions....

Anyway, either way, what is the easiest way to find out what the
Sunday is that I want. (sorry if my rambling makes this more

For instance, today is Sat Feb 9 2008.  I want to be able to determine
that last sunday was 2008-02-03 and the last day in the two week time
period is 2008-02-16 so that I can query a SQL server for all
appointments between this time period.

Thanks for your help.

Re: Date issues

Quoted text here. Click to load it

Relative to today:
strtotime('last Sunday');

Relative to some other date:
strtotime('last Sunday', mktime(0, 0, 0, $month, $day, $year));

Re: Date issues

Quoted text here. Click to load it

Didn't know about that function!  Thanks!

Site Timeline