strtotime But Start on Monday

If I have this date 2013-06-09 (Friday September 6th) but I want to calculate strtotime starting on Sunday, 2013-01-09, How would I do that with the following code?

$rd = ' 2013-06-09';
		//echo $rd.'<br />';
		$pDate = strtotime($rd.' + 1 week'); 
// BUT I want to start at Sunday, always Sunday no matter what day it is//
		$new_date = date('Y-m-d',$pDate);
		echo $new_date;

Open in new window

LVL 8
rgranlundAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Ray PaseurCommented:
<?php // RAY_temp_rgranlund.php
error_reporting(E_ALL);

// SEE http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_28233144.html#a39472019

// CHOOSE WHATEVER IS CORRECT HERE
date_default_timezone_set('UTC');

$rd = ' 2013-06-09';

$new = date('r', strtotime($rd . ' Sunday'));
echo $new;

Open in new window

0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
PortletPaulEE Topic AdvisorCommented:
2013-06-09 <> (Friday September 6th)
2013-06-09  =   (Sunday June 9th)

2013-09-06 =  (Friday September 6th)

It is extremely rare to see YYYY-DD-MM used
To avoid potential ambiguity, it's best to use ISO 8601 (YYYY-MM-DD) dates
http://php.net/manual/en/function.strtotime.php

regarding Ray's suggestion above, I believe that will return "the next Sunday (after)" so you may need to then subtract 7 days.
0
rgranlundAuthor Commented:
Thank you for that link.  It was insightful for me.
0
Ray PaseurCommented:
The rules for strtotime() are pretty stable, but the inputs are worthy of careful testing.  Thanks for the points and best of luck with your project, ~Ray
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
PHP

From novice to tech pro — start learning today.