Created
February 29, 2020 13:04
-
-
Save devbanana/a3aeb50bde25a98a99cf1c4f0084637e to your computer and use it in GitHub Desktop.
Gets the next Monday, Wednesday, or Friday after a given date.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function getNextMwf(DateTime $date): DateInterval | |
{ | |
$m = (clone $date)->modify('next Monday'); | |
$w = (clone $date)->modify('next Wednesday'); | |
$f = (clone $date)->modify('next Friday'); | |
return $date->diff(min($m, $w, $f)); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment