Skip to content

Instantly share code, notes, and snippets.

@YurePereira
Last active January 6, 2017 21:04
Show Gist options
  • Select an option

  • Save YurePereira/0ba11a74b1e4add741c359f732e587bc to your computer and use it in GitHub Desktop.

Select an option

Save YurePereira/0ba11a74b1e4add741c359f732e587bc to your computer and use it in GitHub Desktop.
Pegando datas relativas a data atual
<?php
$now = new DateTime('now');//Valor padrão
$today = new DateTime('today');
$yesterday = new DateTime('yesterday');
$tomorrow = new DateTime('tomorrow');
echo 'Now: ' . $now->format('d-m-Y H:i:m') . PHP_EOL;
echo 'Today: ' . $today->format('d-m-Y H:i:m') . PHP_EOL;
echo 'Yesterday: ' . $yesterday->format('d-m-Y H:i:m') . PHP_EOL;
echo 'Tomorrow: ' . $tomorrow->format('d-m-Y H:i:m');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment