Ver Mensaje Individual
  #1 (permalink)  
Antiguo 01/12/2015, 19:17
tvreal28
 
Fecha de Ingreso: noviembre-2015
Mensajes: 21
Antigüedad: 8 años, 5 meses
Puntos: 0
PHP Cambiar fecha cadena a date

Buenas he encontrado un campo fecha pero esta en varchar pero no puedo cambiarlo a date por que se perderían registros

Tengo que hacer un listado que me muestre ( Mes y Año )
Por ejemplo
con este formato Abril del 2015

podrían ayudarme como se puede convertir en mes y año de una cadena
las fechas estas guardadas así
Año-Mes-Dias
2015-12-24

Dejo comentado en donde se agrega el codigo
<!---
<td width="25" align=center><?php echo $res['icr_fecha_revision1'];?></td>

si lo hago de esta manera me sale asi 2015-12-24
Pero lo que quiero es que salga Diciembre del 2015
--->


Código PHP:
<?php
require_once('conexion.php');

if (isset(
$_GET['busc'])){
$fecha_reporte=$_GET['fecha_reporte'];
$fecha_reporte2=$_GET['fecha_reporte2'];
$sql="select * from tbldocumentosicr INNER JOIN tblinfracciones ON tbldocumentosicr.icr_infraccion=tblinfracciones.icr_infraccion where icr_fecha_ri>='$fecha_reporte' and icr_fecha_ri<='$fecha_reporte2' order by icr_fecha_ri ASC";
}else{
$sql="select * from tbldocumentosicr INNER JOIN tblinfracciones ON tbldocumentosicr.icr_infraccion=tblinfracciones.icr_infraccion where icr_estado='5' order by icr_fecha_ri ASC";
}
$reg=mysql_query($sql,$cnx);
?>
<html>
<head>
<title>Listado</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
    <script type="text/javascript" src="calendar.js"></script>
    <script type="text/javascript" src="calendar-setup.js"></script>
    <script type="text/javascript" src="calendar-es.js"></script>
    <style type="text/css"> @import url("calendar-win2k-cold-1.css"); </style>

<script type="text/javascript" language="javascript">
   function cambiar(id,color){
       document.getElementById(id).style.backgroundColor=color;
   }
</script>
<style type="text/css">
body,td,th {
   color: #000;
}
body {
}
</style>
</head>

<body>
<form action="reportlima.php" method="get" >

<table BGCOLOR="F9FBFC" BORDERCOLOR="EAEAEB"  BORDER="1" width="900" align="center" cellpadding="1" >
<tr>
   <td colspan=6 align="center" BGCOLOR="C1D4D6" style="color:#000000"><h2><strong>Consulta</strong></h2></td>

</tr>

<TR>
<TD align=left><B>Fecha Notificacion RI</B></TD> 

<TR>
<TD align=right><B> Desde:</B></TD>
<TD align=left> <input type="text" name="fecha_reporte" id="fecha_reporte" style="background-color:#FBF9D5"/>
<button type="submit" id="button1">....</button>
<script type="text/javascript">                Calendar.setup({
                                inputField    : "fecha_reporte",
                                button        : "button1",
                                align         : "center"
                              });
                               </script>
</TD></TR>

<TR>
<TD align=right><B> Hasta:</B></TD>
<TD align=left> <input type="text" name="fecha_reporte2" id="fecha_reporte2" style="background-color:#FBF9D5"/>

<button type="submit" id="button2">....</button>
<script type="text/javascript">                Calendar.setup({
                                inputField    : "fecha_reporte2",
                                button        : "button2",
                                align         : "center"
                              });
                               </script>
</TD></TR>
  <TR> 
   <TD colspan=6>
    <br/>

 <center>   
 <input type="submit" name="busc" value="Buscar" style='width:100px; height:35px'>
<input type="button" name="reg" value="Regresar" style='width:100px; height:35px' onClick="history.back()"></center>

 </table>
</form>
<br></br>
<table width="1450"  align="center" cellspacing="0">
<TD align=left><input type="submit" name="exporta" value="Exportar a Excel" style='width:150px; height:35px'></TD>

</table>
<table BGCOLOR="F9FBFC" BORDERCOLOR=""  BORDER=5 width="1450"  align="center" cellspacing="0">
<tr>
 <td colspan=14 align="center" bgcolor="#FFFFFF"><h2><strong></strong></h2></td>
  </tr>
<tr>
   <td BGCOLOR="C1D4D6" width="25" align=center><h5>N °</h5></td>
   <td BGCOLOR="C1D4D6" width="90" align=center><h5>DEPENDENCIA</h5></td>
   <td BGCOLOR="C1D4D6" width="85" align=center><b><h5>RUC</h5></b></td>
   <td BGCOLOR="C1D4D6" width="150" align=center><h5>N CUENTA</h5></td>
   <td BGCOLOR="C1D4D6" width="230" align=center><h5>RAZON SOCIAL</h5></td>
   <td BGCOLOR="C1D4D6" width="100" align=center><h5>CODIGO RESLUCION</h5></td>
   <td BGCOLOR="C1D4D6" width="100" align=center><h5>FECHA NOTIFICACION</h5></td>
 <td BGCOLOR="C1D4D6" width="330" align=center><h5>CAUSAL DE INGRESO</BR>DERECAUDACION</h5></td>
   <td BGCOLOR="C1D4D6" width="100" align=center><h5>TIPO MONTO<BR> A TRASLADAR</h5></td>
   <td BGCOLOR="C1D4D6" width="90" align=center><h5>OBSERVACIONES</h5></td>
   <td BGCOLOR="C1D4D6" width="90" align=center><h5>PERIODOS DE REVISION</h5></td> 
   <td BGCOLOR="C1D4D6" width="90" align=center><h5>MONTO A TRASLADAR</h5></td>
   <td BGCOLOR="C1D4D6" width="70" align=center><h5>ESTADO</h5></td>
  
 </tr>
<?php
$i
=0;
while(
$res=mysql_fetch_array($reg)){
   
?>
   <tr style="background-color:#f0f0f0" id="<?php echo $i;?>" onMouseMove="cambiar('<?php echo $i;?>','#cccccc')" onMouseOut="cambiar('<?php echo $i;?>','#f0f0f0')">

  <td width="25" align=center><?php echo $res[''];?></td>
    <td width="90" align=center>00<?php echo $res['icr_dependencia'];?></td>
    <td width="85" align=center><?php echo $res['icr_ruc'];?></td>
    <td width="150" align=center><?php echo $res['icr_cuenta_bn'];?></td>
    <td width="230" align=justify><?php echo $res['icr_contribuyente'];?></td>
    <td width="100" align=center>0<?php echo $res['icr_dependencia'];?>024000<?php echo $res['icr_num_resolucion'];?></td>
    <td width="100" align=center><?php echo $res['icr_fecha_ri'];?></td>
    <td width="330" align=justify><?php echo $res['icr_causal'];?></td>
    <td width="90" align=center>
<?php if($res["icr_traslado"]==1){?>Saldo Parcial
<?php }elseif($res["icr_traslado"]==2){?>Saldo Total
<?php }?>   </td>
<td width="90" align=justify><?php echo $res[''];?></td>



<!---  AQUI ES DONDE SE DEBE AGREGAR EL CODIGO

<td width="25" align=center><?php echo $res['icr_fecha_revision1'];?></td>

si lo hago de esta manera me  sale asi 2015-12-24
Pero lo que quiero es que salga Diciembre del 2015
--->

<td width="90" align=center><?php echo $res['icr_monto_icr'];?></td>
 
  <td width="70" align=center>
<?php if($res["icr_estado"]==1){?>Registrado
<?php }elseif($res["icr_estado"]==2){?>Con Comunicaci&oacute;n
<?php }elseif($res["icr_estado"]==3){?>Notificación Comunicación
<?php }elseif($res["icr_estado"]==4){?>Con Resoluci&oacute;n
<?php }elseif($res["icr_estado"]==5){?>Notificado con RI
<?php }elseif($res["icr_estado"]==6){?>Reportado
<?php }?>
   </td>

</tr>
<?php
$i
=$i+1;
}
?>
</table>
</body>

</html>