문제

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;
도움이 되었습니까?

해결책

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;

다른 팁

<?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

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top