Re: cast string to time!

From: Date: Mon, 17 Jul 2000 07:19:54 +0000
Subject: Re: cast string to time!
References: 1  Groups: php.general.es 
Request: Send a blank email to general-es+get-507@lists.php.net to get a copy of this message
Puedes usar el ereg (http://www.php.net/manual/function.ereg.php) para parsear la cadena y luego crear el nuevo formato: $laFecha = "20-5-2000"; if ( ereg( "([0-9]{1,2})-([0-9]{1,2})-([0-9]{4})", $laFecha, $partes ) ) printf( "%4d-%02d-%02d", $partes[3], $partes[2], $partes[1] ); else echo "Fecha no válida $laFecha"; O por ejemplo, en MySQL usar el DATE_FORMAT (http://www.mysql.com/documentation/mysql/bychapter/manual_Reference.html#Da te_and_time_functions) para hacer el paso contrario ( reformatar el campo de la BD según el formato del string ). $laFecha = "20-5-2000"; $query = "SELECT * FROM tabla WHERE DATE_FORMAT(fecha,'%e-%c-%Y') = '$laFecha'"; Un saludo. ----- Original Message ----- From: "Eduardo Garcia" <jegart@usa.net> To: <lista@phpes.com> Sent: Saturday, July 15, 2000 12:17 AM Subject: [PHP-ES] cast string to time! > Hi everybody.. > > I have a string in my php code and i need to compare the variable with one of > time type in a sentence SQL, some of you knows like doing cast of string to > time?? > > thanks.. > > Santa Marta > Magdalena > Colombia > Sur America > Usuario Linux # > > > ____________________________________________________________________ > Get free email and a permanent address at > http://www.netaddress.com/?N=1 > > --------------------------------------------------------------------- > Para dar de baja la suscripción, mande un mensaje a: > lista-unsubscribe@phpes.com

« previous php.general.es (#507) next »