Last active
December 19, 2015 21:58
-
-
Save fmagrosoto/6023783 to your computer and use it in GitHub Desktop.
Formatear fecha MySQL en una forma humanamente legible, incluye opción para poner hora
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * FORMATEAR FECHA | |
| * | |
| * Formatear la fecha de formato MySQL a formato humanamente legible. | |
| * Incluye opción para mostrar la hora o no. | |
| * @author Fernando Magrosoto | |
| */ | |
| function formatearFecha($fecha, $phora){ | |
| $fechaO = explode(" ",$fecha); | |
| $fechaA = $fechaO[0]; | |
| $hora = $fechaO[1]; | |
| $fechaB = explode("-",$fechaA); | |
| $agno = $fechaB[0]; | |
| $mes = $fechaB[1]; | |
| $dia = $fechaB[2]; | |
| switch ($mes){ | |
| case "01": | |
| $Nmes = "enero"; | |
| break; | |
| case "02": | |
| $Nmes = "febrero"; | |
| break; | |
| case "03": | |
| $Nmes = "marzo"; | |
| break; | |
| case "04": | |
| $Nmes = "abril"; | |
| break; | |
| case "05": | |
| $Nmes = "mayo"; | |
| break; | |
| case "06": | |
| $Nmes = "junio"; | |
| break; | |
| case "07": | |
| $Nmes = "julio"; | |
| break; | |
| case "08": | |
| $Nmes = "agosto"; | |
| break; | |
| case "09": | |
| $Nmes = "septiembre"; | |
| break; | |
| case "10": | |
| $Nmes = "octubre"; | |
| break; | |
| case "11": | |
| $Nmes = "noviembre"; | |
| break; | |
| case "12": | |
| $Nmes = "diciembre"; | |
| break; | |
| } | |
| if($phora == 1){ | |
| $salidaFecha = $dia. " de ".$Nmes." de ".$agno. " - ".$hora; | |
| } else if($phora == 0) { | |
| $salidaFecha = $dia. " de ".$Nmes." de ".$agno; | |
| } | |
| return $salidaFecha; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment