Skip to content

Instantly share code, notes, and snippets.

@parzibyte
Created July 29, 2019 22:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save parzibyte/5185448ece2bde02ae7a51d957cda543 to your computer and use it in GitHub Desktop.
Save parzibyte/5185448ece2bde02ae7a51d957cda543 to your computer and use it in GitHub Desktop.
<?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