Question

At the date/time of this error, it is, "3/24/2014 7:08AM". Normally, running "2 Sunday ago" on strtotime() will result in going back to 2 sundays. So it'll result in, 3/16. However, it is landing on 3/23, which is last sunday. Also, running "1 Sunday ago" will result in a future date of 3/30 and not 3/23. I'm assuming its some kind of settings issue but don't know how to debug. Any help would be great.

Thanks!

$start = date( "Y-m-d 11:00:00", strtotime("2 Sunday ago"));
$end = date( "Y-m-d 11:00:00", strtotime("Last Sunday"));
echo $start . ' - ' . $end;
Was it helpful?

Solution

Try with

 $start = date( "Y-m-d 11:00:00", strtotime("-2 weeks sunday"));
 $end = date( "Y-m-d 11:00:00", strtotime("-1 weeks sunday"));
 echo $start . ' - ' . $end;

OTHER TIPS

<?php
$start = date( "Y-m-d 11:00:00", strtotime("-2 sunday"));
$end = date( "Y-m-d 11:00:00", strtotime("last sunday"));
echo $start . ' - ' . $end;
?>

example

Your Code is Working Fine with PHP version 5.3+ check it here

You can use -2 weeks sunday instead it works on all (4.3+) PHP versions check out here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top