1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465 |
- <?php
- /*
- * To change this license header, choose License Headers in Project Properties.
- * To change this template file, choose Tools | Templates
- * and open the template in the editor.
- */
- $diasArr = explode(",", "1,3");
- $weekTxt = array(1=>"first", 2=>"second", 3=>"third", 4=>"fourth", -1=>"last");
- $dayname = array("sun", "mon", "tue", "wed", "thu", "fri", "sat");
- //($evento["CalendarioReglas_semana"])
- $fechaIni = "2021-02-02 00:00:00";
- $semana = 2;
- /*for($semana = 1; $semana<=4; $semana++){
- $d = $diasArr[0];
- $fecha = date ("Y-m-01", strtotime($fechaIni));
- if($semana == 1 && intval(date("w", strtotime($fecha))) == intval($d) ){
- echo "<p><b>".$fecha."</b></p>";
- }else{
- if(intval(date("w", strtotime($fecha))) == intval($d)){
- echo "<p>[".$fecha."]".date ("Y-m-d", strtotime($weekTxt[$semana-1]." ".$dayname[$d], strtotime($fecha)))."</p>";
- }else{
- echo "<p>[".$fecha."]".date ("Y-m-d", strtotime($weekTxt[$semana]." ".$dayname[$d], strtotime($fecha)))."</p>";
- }
- }
- }*/
- //El bueno
- $fecha = date ("Y-m-01", strtotime($fechaIni));
- while (strtotime($fecha) <= strtotime('2021-06-01')) {
- foreach($diasArr as $d){
- //echo "-->". intval(date("w", strtotime($fecha)))." == ". intval($d)."[".$fecha."]";
- if($semana == 1 && intval(date("w", strtotime($fecha))) == intval($d) ){
- echo "<p><b>".$fecha."</b></p>";
- }else{
- if(intval(date("w", strtotime($fecha))) == intval($d)){
- echo "<p>".date ("Y-m-d", strtotime($weekTxt[$semana-1]." ".$dayname[$d], strtotime($fecha)))."</p>";
- }else{
- echo "<p>".date ("Y-m-d", strtotime($weekTxt[$semana]." ".$dayname[$d], strtotime($fecha)))."</p>";
- }
- }
- }
- $fecha = date ("Y-m-01", strtotime("+1 month", strtotime($fecha)));
- //echo "<i>".$fecha."</i>";
- }
- /*echo "<h3>".date ("Y-m-01", strtotime("+1 month ", strtotime('2021-03')))."</h3>";
- */
- /*$dateObj = new DateTime($fecha);
- $dateObj->modify('first day of');
- $dateObj->modify('first mon');
- $dateLastObj = new DateTime('2021-06-01');
- while($dateObj < $dateLastObj){
- echo "<p>".$dateObj ->format('m-d-Y')."</p>";
- $dateObj->modify('+1 month');
- $dateObj->modify('first mon');
- }
- */
|