Created
July 29, 2019 22:04
-
-
Save parzibyte/5185448ece2bde02ae7a51d957cda543 to your computer and use it in GitHub Desktop.
Extraer datos de fecha actual https://parzibyte.me/blog/2018/07/30/extraer-anio-mes-dia-fecha-php/
This file contains 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
<?php | |
/* | |
Gran nota: cuando llamamos a date y | |
no le pasamos el segundo argumento, | |
se asume que la fecha es time() por | |
lo que... | |
$fechaEntera = time(); | |
$anio = date("Y", $fechaEntera); | |
Es lo mismo que... | |
$anio = date("Y"); | |
*/ | |
$fechaEntera = time(); | |
$anio = date("Y", $fechaEntera); | |
$mes = date("m", $fechaEntera); | |
$dia = date("d", $fechaEntera); | |
$hora = date("H", $fechaEntera); | |
$minutos = date("i", $fechaEntera); | |
$segundos = date("s", $fechaEntera); | |
#Notar que es lo mismo que hacer | |
# date("Y-m-d H:i:s") | |
echo "$anio-$mes-$dia $hora:$minutos:$segundos"; | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment