Foros del Web » Programando para Internet » PHP »

Exportar fecha Unix a d/m/Y a CSV

Estas en el tema de Exportar fecha Unix a d/m/Y a CSV en el foro de PHP en Foros del Web. Hola muy buenas tengo el siguiente problema, estoy intentando exportar los registros de una base de datos a un archivo csv conseguir lo consegui. PERO ...
  #1 (permalink)  
Antiguo 15/05/2009, 09:34
 
Fecha de Ingreso: enero-2009
Mensajes: 3
Antigüedad: 15 años, 3 meses
Puntos: 0
Exportar fecha Unix a d/m/Y a CSV

Hola muy buenas tengo el siguiente problema, estoy intentando exportar los registros de una base de datos a un archivo csv conseguir lo consegui.

PERO tengo un problema al traer la fecha al archivo ya que de devuelve el dato en Unix y lo quiero en formato d/m/Y para guardarlo no tube ningun tipo de problema utilize esto strtotime(date_convert($_POST['date'].

A continuacion os pongo el codigo, la cuestion es que se como pasar el Unix al formato que quiero pero no se como exportarlo

Código PHP:
Engineer,Date,Job Type,Channel,Location,Area,Customer Name,Job Reference,Serial Number,Start,Arrival,Finish,Travel Time,Time on Site,Total Time,
<?php require_once('../../Connections/auth.php'); ?>
<?php $fecha 
$row_report['date']; ?> 
<?php echo date "d/m/Y" $fecha ); ?>
<?php 
if (!function_exists("GetSQLValueString")) {
function 
GetSQLValueString($theValue$theType$theDefinedValue ""$theNotDefinedValue ""
{
  
$theValue get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

  
$theValue function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

  switch (
$theType) {
    case 
"text":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;    
    case 
"long":
    case 
"int":
      
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
      break;
    case 
"double":
      
$theValue = ($theValue != "") ? "'" doubleval($theValue) . "'" "NULL";
      break;
    case 
"date":
      
$theValue = ($theValue != "") ? "'" $theValue "'" "NULL";
      break;
    case 
"defined":
      
$theValue = ($theValue != "") ? $theDefinedValue $theNotDefinedValue;
      break;
  }
  return 
$theValue;
}
}
mysql_select_db($database_auth$auth);
$query_report "SELECT * FROM tsr_services";
$report mysql_query($query_report$auth) or die(mysql_error());
$row_report mysql_fetch_assoc($report);
$totalRows_report mysql_num_rows($report);
 
//here type the name for the fields

$sacar=mysql_query("select * from tsr_services"$auth);

while (
$reg mysql_fetch_array($sacar))
{
$shtml $shtml.$reg["engineer"].",".$reg["date"].",".$reg["jobtype"].",".$reg["channel"].",".$reg["location"].",".$reg["area"].",".$reg["customername"].",".$reg["jobref"].",".$reg["serialnumber"].",".$reg["start"].",".$reg["arrival"].",".$reg["finish"].",".$reg["time_travelled"].",".$reg["time_on_site"].",".$reg["total_time"]. "\n";}
//we have to tell the browser that we'll send a csv file
header("Content-Description: File Transfer");
header("Content-Type: application/force-download");
header("Content-Disposition: attachment; filename=tsr.report.csv");
echo 
$shtml;

mysql_free_result($report);
?>
Espero haberme explicado bien. cualquier duda aki estoy. me estoy volviendo loco!! lo doy puesto en mi formato pero no me lo exporta al excel.
Para pasarlo de unix al formato que quiero lo hago de la siguiente manera

<?php $fecha = '$row_report['date']'; ?>
<?php echo date ( "d/m/Y" , $fecha ); ?>

Alguien me puede ayudar muchas gracias de antemano
  #2 (permalink)  
Antiguo 16/05/2009, 20:22
Avatar de GatorV
$this->role('moderador');
 
Fecha de Ingreso: mayo-2006
Ubicación: /home/ams/
Mensajes: 38.567
Antigüedad: 17 años, 10 meses
Puntos: 2135
Respuesta: Exportar fecha Unix a d/m/Y a CSV

Tema trasladado desde Bases de Datos

http://www.forosdelweb.com/f21/funci...-datos-413499/
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 16:40.