Bueno este si que es un mini howto normalmente recibimos las fechas que vamos a guardar en formato dd/mm/yyyy pero en mysql las guardamos en formato yyyy/mm/dd
asi que sin mas aqui les dejo la manera practica que el jegs encontro para hacer la conversion

list($dia,$mes,$anio)=explode("/",$fecha);
$fecha="$anio-$mes-$dia";

Y asi de facil podemos convertir las fechas que recibimos en formato mysql ahora vamos a la inversa formatear la fecha de regreso de Mysql a PHP
la consulta quedaria asi

2 Respuestas para “Convertir fechas entre MySQL y castellano”

  1. opotonil
    desde Spain Dijo:

    Otro sistema:
    $fecha=date(“d/m/Y”, strtotime($date))

    Responder

  2. Junior
    desde Thailand Dijo:

    This is a very good resource for leanring these topics. It is not for absolute beginners. You need to have a working knowledge of html and how websites work. I suggest that you should have coded a website, and reached a point where you want to do something specific, but cannot figure out how.I have been checking out every book I can find from my library that covers PHP/MySQL, JavaScript, and HTML/CSS. My wife balked at how many books I had. It was a stack of thick dull texts LITERALLY 5 feet tall. They were all dense, boring, and assumed that I knew things that only a web developer would know. I would read a chapter or two in each before I could go no further.Out of all of those books, this is the one book I bought.Now, this is still a thick, dense book. The author tries his best to make the book enjoyable to read. He gives good examples, and immediately explains why he does things this way, how things might be different, what mistakes you might make, and how you would implement this new knowledge. It is this explanation that makes this book worth buying. Every other book will tell you something and move on. I assume that other authors take for granted that they know the why’s and how’s and such, that they do not want to waste time on details that seem tedious to them. This author really works hard to make the content as easy to understand as possible.This means that there are parts I am familiar with and skip over. That is fine. For the parts I struggle with, I am very grateful to have all of the expounded information available.I cannot speak about updates from the 1st edition, since I did not read it. I will most likely buy the next edition, if the changes/additions are substantial. I would like to see more on forms and cookies. There really is no good book about forms and cookies, and the two chapters here are very good. and I would like the putting it all together chapter at the end to be substantially longer. That ending chapter was my favorite part. I don’t know what else he can add to this book other than a section on html 5.All in all, this is a great book. Buy it.

    Responder

Responder