1 - get the current timestamp 2 - do the offset sum 3 - minus the offset off the time 4 - echo out the new timestamp in date format.

If you want to go back in the week you just need to change the 24 to 48 or 72 etc.

And if you want to go forward change the minus to a plus. $lastmonday = $timestamp + $mondayoffset;

Hope it helps.

sampson123

5:29 pm on Mar 11, 2011 (gmt 0)

Thanks for the reply, Orangutang. Hmm.. Although that outputs: "The monday that just happened was 2011_03_10." and that ain't right.

The 10th was a thursday, not Monday.

Orangutang

5:45 pm on Mar 11, 2011 (gmt 0)

Hi Sampson,

Then I mis-understood, I wasn't sure if I had. I was just looking at what you posted, copy and pasted it and started playing around with it to try to learn something myself. When I arrived at what I posted I looked at your question again, saw it had been going on a bit and thought it was worth a post.

Just trying to help mate. :-)

sampson123

6:17 pm on Mar 11, 2011 (gmt 0)

And I appreciate it!

I'd like to think I'm pretty darn decent at programming, but this takes a lobe of my brain that just doesn't make an sense to me! I can't for the life of me figure this out...

Orangutang

7:23 pm on Mar 11, 2011 (gmt 0)

I know what you mean, I'm trying to learn php and what I've learnt so far is there's loads and loads to learn. :-)

You've got me now, there's this bit of code that I couldn't get my head round:

$todayday = date("w", $timestamp);

And I couldn't understand this:

$sundayoffset = 60 * 60 * 24 * $todayday;

Your multiplying 60 * 60 * 24 which gives you a day in seconds then you want to multiply that by, and there's where I got lost.