Ver Mensaje Individual
  #1 (permalink)  
Antiguo 15/05/2009, 09:34
thismad
 
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