Skip to content

Instantly share code, notes, and snippets.

@m8rge
Created June 27, 2017 04:52
Show Gist options
  • Save m8rge/e2c927824b86cb8e7088cc06ce94ba95 to your computer and use it in GitHub Desktop.
Save m8rge/e2c927824b86cb8e7088cc06ce94ba95 to your computer and use it in GitHub Desktop.
Как правильно посмотреть, что одна дата больше другой на N дней
<?php
$date1 = new \DateTime('2017-01-01');
$date2 = new \DateTime('2017-01-10');
$dateInterval = $date1->diff($date2); // this is not date1-date2, but date2-date1 :-(
var_dump($dateInterval->format('%r%a') > 3); // :-(
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment