dates.php 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. <?php
  2. /*
  3. * To change this license header, choose License Headers in Project Properties.
  4. * To change this template file, choose Tools | Templates
  5. * and open the template in the editor.
  6. */
  7. $diasArr = explode(",", "1,3");
  8. $weekTxt = array(1=>"first", 2=>"second", 3=>"third", 4=>"fourth", -1=>"last");
  9. $dayname = array("sun", "mon", "tue", "wed", "thu", "fri", "sat");
  10. //($evento["CalendarioReglas_semana"])
  11. $fechaIni = "2021-02-02 00:00:00";
  12. $semana = 2;
  13. /*for($semana = 1; $semana<=4; $semana++){
  14. $d = $diasArr[0];
  15. $fecha = date ("Y-m-01", strtotime($fechaIni));
  16. if($semana == 1 && intval(date("w", strtotime($fecha))) == intval($d) ){
  17. echo "<p><b>".$fecha."</b></p>";
  18. }else{
  19. if(intval(date("w", strtotime($fecha))) == intval($d)){
  20. echo "<p>[".$fecha."]".date ("Y-m-d", strtotime($weekTxt[$semana-1]." ".$dayname[$d], strtotime($fecha)))."</p>";
  21. }else{
  22. echo "<p>[".$fecha."]".date ("Y-m-d", strtotime($weekTxt[$semana]." ".$dayname[$d], strtotime($fecha)))."</p>";
  23. }
  24. }
  25. }*/
  26. //El bueno
  27. $fecha = date ("Y-m-01", strtotime($fechaIni));
  28. while (strtotime($fecha) <= strtotime('2021-06-01')) {
  29. foreach($diasArr as $d){
  30. //echo "-->". intval(date("w", strtotime($fecha)))." == ". intval($d)."[".$fecha."]";
  31. if($semana == 1 && intval(date("w", strtotime($fecha))) == intval($d) ){
  32. echo "<p><b>".$fecha."</b></p>";
  33. }else{
  34. if(intval(date("w", strtotime($fecha))) == intval($d)){
  35. echo "<p>".date ("Y-m-d", strtotime($weekTxt[$semana-1]." ".$dayname[$d], strtotime($fecha)))."</p>";
  36. }else{
  37. echo "<p>".date ("Y-m-d", strtotime($weekTxt[$semana]." ".$dayname[$d], strtotime($fecha)))."</p>";
  38. }
  39. }
  40. }
  41. $fecha = date ("Y-m-01", strtotime("+1 month", strtotime($fecha)));
  42. //echo "<i>".$fecha."</i>";
  43. }
  44. /*echo "<h3>".date ("Y-m-01", strtotime("+1 month ", strtotime('2021-03')))."</h3>";
  45. */
  46. /*$dateObj = new DateTime($fecha);
  47. $dateObj->modify('first day of');
  48. $dateObj->modify('first mon');
  49. $dateLastObj = new DateTime('2021-06-01');
  50. while($dateObj < $dateLastObj){
  51. echo "<p>".$dateObj ->format('m-d-Y')."</p>";
  52. $dateObj->modify('+1 month');
  53. $dateObj->modify('first mon');
  54. }
  55. */