Skip to content

Instantly share code, notes, and snippets.

@YurePereira
Created January 7, 2017 15:47
Show Gist options
  • Select an option

  • Save YurePereira/14cccec17019e7cd7576b0671b98cfa5 to your computer and use it in GitHub Desktop.

Select an option

Save YurePereira/14cccec17019e7cd7576b0671b98cfa5 to your computer and use it in GitHub Desktop.
Comparando condicionalmente duas datas
<?php
$now = new DateTime();
$today = new DateTime('today');
$yesterday = new DateTime('yesterday');
$tomorrow = new DateTime('tomorrow');
if ($now >= $today) {
echo $now->format('d/m/Y H:i:s') . ' it greater ' . $today->format('d/m/Y H:i:s') . PHP_EOL;
}
if ($yesterday <= $tomorrow) {
echo $yesterday->format('d/m/Y H:i:s') . ' it smaller ' . $tomorrow->format('d/m/Y H:i:s') . PHP_EOL;
}
if ($today != $tomorrow) {
echo $today->format('d/m/Y H:i:s') . ' is different from ' . $tomorrow->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