Skip to content

Instantly share code, notes, and snippets.

@jgdoncel
Created May 10, 2016 12:28
Show Gist options
  • Save jgdoncel/9c43fbdcec849108d2d523f9c2de3193 to your computer and use it in GitHub Desktop.
Save jgdoncel/9c43fbdcec849108d2d523f9c2de3193 to your computer and use it in GitHub Desktop.
Parsear una fecha y sumarle horas
$fecha = date_create_from_format('d/m/Y H:i:s', '08/09/1969 15:32:21');
echo "Fecha: " . $fecha->format('Y-m-d H:i:s') . "<br/>";
$horas = 24;
echo "Fecha+24h: " . $fecha->add(new \DateInterval('PT' . $horas . 'H'))->format('Y-m-d H:i:s') . "<br/>";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment