PHP - Ayuda con formato hora

 
Vista:
sin imagen de perfil
Val: 28
Ha aumentado su posición en 8 puestos en PHP (en relación al último mes)
Gráfica de PHP

Ayuda con formato hora

Publicado por Oscar (14 intervenciones) el 17/10/2017 05:13:16
Buen dia a todos, tengo el siguiente código que me muestra una hora en formato UNIX (ejemplo: 1508209407), eh investigado y me comentan que únicamente hay que pasarlo por el comando "date", ya lo eh intentado en varias ocasiones pero no logro que me funcione. el cogido es el siguiente:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
<html>
<head>
<TITLE>Consulta de Usuarios</TITLE>
<link rel="shortcut icon" href="imagenes/favicon.ico" />
<link rel='stylesheet' type='text/css' href='css/styles.css' />
    <link rel="stylesheet" href="libs/qunit/qunit.css">
    <script src="libs/qunit/qunit.js"></script>
    <script src="libs/polyfill.js"></script>
<style type="text/css">
.datagrid table { border-collapse: collapse; text-align: left; width: 100%; } .datagrid {font: normal 12px/150% Verdana, Arial, Helvetica, sans-serif; background: #fff; overflow: hidden; border: 2px solid #841212; width: 100%; -webkit-border-radius: 3px; -moz-border-radius: 3px; border-radius: 3px; }.datagrid table td, .datagrid table th { padding: 9px 10px; }.datagrid table thead th {background:-webkit-gradient( linear, left top, left bottom, color-stop(0.05, #841212), color-stop(1, #8F171F) );background:-moz-linear-gradient( center top, #F72735 5%, #8F171F 100% );filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#F72735', endColorstr='#8F171F');background-color:#F72735; color:#FFFFFF; font-size: 15px; font-weight: bold; border-left: 2px solid #841212; } .datagrid table thead th:first-child { border: none; }.datagrid table tbody td { color: #000000; border-left: 2px solid #841212;font-size: 12px;font-weight: bold; }.datagrid table tbody .alt td { background: #D9D9D9; color: #000000; }.datagrid table tbody td:first-child { border-left: none; }.datagrid table tbody tr:last-child td { border-bottom: none; }.datagrid table tfoot td div { border-top: 1px solid #841212;background: #FFFFFF;} .datagrid table tfoot td { padding: 0; font-size: 12px } .datagrid table tfoot td div{ padding: 3px; }
</style>
<style type="text/css">
  .boton_personalizado{
    text-decoration: none;
    padding: 10px;
    font-weight: 600;
    font-size: 20px;
    color: #ffffff;
    background-color: #1883ba;
    border-radius: 6px;
    border: 2px solid #0016b0;
  }
</style>
</head>
<center>
<body>
    <p align="right"><a class="boton_personalizado" target="_blank" href="/sistema/dispositivos.html">Ver Disositivos Utilizados</a>
<br/></p>
<div class="datagrid"><table id="demo" align="center" border="0" cellpadding="2" cellspacing="2">
<thead><th colspan="1" rowspan="1" align="center">Nombre de Sucursal</th> <th colspan="1" rowspan="1" align="center">Fecha de Registro</th><th width='150' colspan="1" rowspan="1" align="center">Hora del Registro</th><th width='150' colspan="1" rowspan="1" align="center">Tipo del Registro</th></thead>
 
<?php
include('conexion.php');
    $query = "select * from tbinout";
    $result = mysql_query($query);
 
    while ($registro = mysql_fetch_array($result)){
echo "
    <tr> 
      <td width='150'>".$registro['cedchkprof']."</td>
      <td width='150'><center>".$registro['diachkprof']."</center></td>
      <td width='150'>".$registro['horachkprof']."</td>
      <td width='150'>".$registro['registrochk']."</td>
      
</tr> 
";
}
?>
<?php
$numero = mysql_num_rows($result);
 
echo"
<thead><th width='150' colspan='7' rowspan='7' align='center'>El Total de Registros es de: $numero</th></thead>
";
?>
</tbody>
   </table>
 
        <script src="libs/tablefilter.js"></script>
        <script src="libs/test-alternate-rows.js"></script>
 
 
</div>
</body>
</center>
</html>

Eh revisado la base de datos y estos se muestran de esa manera (1508209407), pero según me comentaron en este mismo código puedo convertirlo ya que no tengo acceso a el otro sistema que inyecta los primero datos.

Espero alguien me pueda ayudar con este problema que tengo ya que no eh podido solucionarlo.

Muchas gracias!
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
sin imagen de perfil
Val: 604
Bronce
Ha mantenido su posición en PHP (en relación al último mes)
Gráfica de PHP

Ayuda con formato hora

Publicado por Miguel (218 intervenciones) el 17/10/2017 07:22:25
Usa:

1
$hora = date("G:i:s", 1508209407); // usando formato de 24 hrs
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
Imágen de perfil de Alejandro

Ayuda con formato hora

Publicado por Alejandro (54 intervenciones) el 17/10/2017 13:13:08
Oscar,

También puedes obtener fecha/hora:

1
echo date('Y-m-d H:i:s', 1508209407);

Saludos.
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
1
Comentar
sin imagen de perfil
Val: 28
Ha aumentado su posición en 8 puestos en PHP (en relación al último mes)
Gráfica de PHP

Ayuda con formato hora

Publicado por Oscar (14 intervenciones) el 17/10/2017 17:38:03
Excelente ya quedo solucionado, muchas gracias a ambos!
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar