PHP - ayuda Primer dia y ultimo dia

 
Vista:

ayuda Primer dia y ultimo dia

Publicado por Erick Soto (4 intervenciones) el 15/05/2009 15:25:59
Holas, me pueden a ayudar a generar un algoritmo para generar el primer día y el ultimo día de cada semana

Asi.
Año Semana Inicio Fin
2009 1 4/01 10/01
2009 2 11/01 17/01
. . . .
. . . .
2009 52 20/12 26/12

Este es el codigo

<form name="form1" action="?" method="post">
<? $year=date('Y');
$fech="December 31, ".$year;
$tot_sem=date('W', strtotime($fech));?> <!-- Total de semanas por año -->
<table border="0" cellpadding="0" cellspacing="0" width="300px" align="center">
<tr>
<td>
<table width="100%" border="1" cellspacing="0" cellpadding="0" style="border: solid 1px #900; border-collapse:collapse;">
<tbody>
<tr class="title_td" align="center">
<td width="25%">Año</td>
<td width="25%">Semana</td>
<td width="25%">Inicio</td>
<td width="25%">Fin</td>
</tr>
<? for($i=1; $i<=$tot_sem; $i++ ) { ?>
<tr>
<td><?=$year;?></td>
<td><?=$i;?></td>
<td><? echo date("d-m",mktime(0,0,0,date("m"),date("j") - date("w"),date("Y")));?></td>
<td><? echo date("d-m",mktime(0,0,0,date("m"),date("j") - date("w")+6,date("Y")));?></td>
</tr>
<? } ?>
<tr>
<td colspan="2">Total Semanas:</td>
<td colspan="2"><?=$tot_sem;?></td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
<td> </td>
</tr>
</tbody>
</table>
</td>
</tr>
</table>

</form>

Pero solo me sale

Año Semana Inicio Fin
2009 1 10-05 16-05
2009 2 10-05 16-05
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder