Skip to content

Instantly share code, notes, and snippets.

@YurePereira
Last active June 19, 2019 14:52
Show Gist options
  • Select an option

  • Save YurePereira/53c7dae30f0844bf158ab181c7d9610a to your computer and use it in GitHub Desktop.

Select an option

Save YurePereira/53c7dae30f0844bf158ab181c7d9610a to your computer and use it in GitHub Desktop.
Subtraindo um intervalo de tempo de uma data
<?php
$dateTime = new DateTime('2016-12-01 00:00:01');
echo $dateTime->format('d/m/Y H:i:s') . PHP_EOL;
//Subtraindo 3 anos e 2 meses de nossa data
$dateTime->sub(new DateInterval('P3Y2M'));
echo $dateTime->format('d/m/Y H:i:s');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment