Skip to content

Instantly share code, notes, and snippets.

@LouLeGrain
Last active May 1, 2018 13:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LouLeGrain/db23addd3b543fbb3d0f1a59fce9bc9b to your computer and use it in GitHub Desktop.
Save LouLeGrain/db23addd3b543fbb3d0f1a59fce9bc9b to your computer and use it in GitHub Desktop.
[Comparaison de dates] Comparer si aujourd'hui est entre deux dates #PHP #Dates
public static function isVotingTime()
{
$dateEnd = new DateTime("03/31/2019", new DateTimeZone('Europe/Paris'));
$dateEndRelative = new DateTime("03/31/2019 last day of +1 month", new DateTimeZone('Europe/Paris'));
//Pour avoir +1 mois pile, on peut avoir des incohérences selon le nombre de jours
$dateBeginningVote = new DateTime("03/19/2018", new DateTimeZone('Europe/Paris'));
$today = new DateTime("now", new DateTimeZone('Europe/Paris'));
if ($today > $dateBeginningVote && $today < $dateEndRelative) {
return true;
} else {
return false;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment