Advertisement
Guest User

Untitled

a guest
May 5th, 2015
214
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. date_default_timezone_set("Europe/Rome");
  2. $today = new DateTime();
  3. $numDay = date("w");
  4. //echo "<br>today = ".$today->format('Y-m-d H:i:s');
  5.  
  6. switch($numDay){
  7. //monday
  8. case 1 :
  9. $startWeek = $today->format('Y-m-d 00:00:00');
  10. $endWeek = $today->modify('next sunday')->format('Y-m-d 23:59:59');
  11. break;
  12. /*//sunday
  13. case 0 :
  14. $startWeek = $today->modify('last monday')->format('Y-m-d 00:00:00');
  15. $endWeek = $today->format('Y-m-d 23:59:59');
  16. break;*/
  17. default:
  18. $startWeek = $today->modify('last monday')->format('Y-m-d 00:00:00');
  19. $endWeek = $today->modify('next sunday')->format('Y-m-d 23:59:59');
  20. break;
  21. }
  22.  
  23. //echo "<br><br>start week = ".$startWeek;
  24. //echo "<br>end week = ".$endWeek;
  25.  
  26. $startMonth = $today->modify('first day of this month')->format('Y-m-d H:i:s');
  27. $endMonth = $today->modify('last day of this month')->format('Y-m-d 23:59:59');
  28.  
  29. //echo "<br><br>start month = ".$startMonth;
  30. //echo "<br>end month = ".$endMonth;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement