Foros del Web » Programando para Internet » PHP »

formato de fechas php(sqlServer)

Estas en el tema de formato de fechas php(sqlServer) en el foro de PHP en Foros del Web. Hola chicos, tengo un problema q no logro arreglar, a ver si alguien me puede ayudar... Consulto un campo de tipo fecha en sql server, ...
  #1 (permalink)  
Antiguo 12/06/2002, 06:27
 
Fecha de Ingreso: mayo-2002
Mensajes: 88
Antigüedad: 21 años, 10 meses
Puntos: 0
formato de fechas php(sqlServer)

Hola chicos, tengo un problema q no logro arreglar, a ver si alguien me puede ayudar...

Consulto un campo de tipo fecha en sql server, que tiene de formato 3/3/99 p.e., pues bien, en php sale de la sgte forma:

2002-06-12 00:00:00.000

He intentado darle formato con la función date de la sgte forma:

echo date('d/ n/ Y',odbc_result($queryC,1))

y le da bien el formato, pero en vez de salir la fecha que extrae de la base de datos, sale siempre la misma fecha, 1/7/70 ó algo así, que debe ser la fecha inicial de la función ó algo por el estilo.

¿alguien sabe qué está ocurriendo??. Os agracezco mucho la ayuda. :)
  #2 (permalink)  
Antiguo 13/06/2002, 05:12
 
Fecha de Ingreso: enero-2002
Mensajes: 132
Antigüedad: 22 años, 2 meses
Puntos: 1
Re: formato de fechas php(sqlServer)

Hola,

prueba a poner esto....

echo date('d - m - y',odbc_result($queryC,1));

Comprueba que $queryC,1 sea el campo fecha...

... si sigue sin salirte aquí te pongo un poco de información sobre el formateo de fechas en mysql...




Funcion DATE_FORMAT de MYsql es...

DATE_FORMAT(date,format)
Formats the date value according to the format string. The following
specifiers may be used in the format string:
%M Month name (January..December)
%W Weekday name (Sunday..Saturday)
%D Day of the month with English suffix (1st, 2nd, 3rd, etc.)
%Y Year, numeric, 4 digits
%y Year, numeric, 2 digits
%X Year for the week where Sunday is the first day of the week, numeric,
4 digits, used with '%V'
%x Year for the week, where Monday is the first day of the week, numeric,
4 digits, used with '%v'
%a Abbreviated weekday name (Sun..Sat)
%d Day of the month, numeric (00..31)
%e Day of the month, numeric (0..31)
%m Month, numeric (01..12)
%c Month, numeric (1..12)
%b Abbreviated month name (Jan..Dec)
%j Day of year (001..366)
%H Hour (00..23)
%k Hour (0..23)
%h Hour (01..12)
%I Hour (01..12)
%l Hour (1..12)
%i Minutes, numeric (00..59)
%r Time, 12-hour (hh:mm:ss [AP]M)
%T Time, 24-hour (hh:mm:ss)
%S Seconds (00..59)
%s Seconds (00..59)
%p AM or PM
%w Day of the week (0=Sunday..6=Saturday)
%U Week (0..53), where Sunday is the first day of the week
%u Week (0..53), where Monday is the first day of the week
%V Week (1..53), where Sunday is the first day of the week. Used with
'%X'
%v Week (1..53), where Monday is the first day of the week. Used with
'%x'
%% A literal `%'.


Ejemplo....

SELECT date_format(lastaccesstime, '%M %e, %Y') FROM user WHERE userid =
'hecky';

.




Un saludo, esperando ser de ayuda...
COMUN

<a href='ir.asp?http://www.califato.com' target='_blank'>http://www.califato.com...</a>
<a href='ir.asp?http://www.califato.net' target='_blank'>http://www.califato.net...</a>

<center>
<img src="http://membres.lycos.fr/dipro/new/logo.gif" border=0 width="100" height="30">
<a href='ir.asp?http://dipro.califato.com' target='_blank'>http://dipro.califato.com...</a>
</
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 07:17.