Created
August 29, 2019 16:40
-
-
Save MrSam/37cca0641d4a036ca0242e754c9b0c47 to your computer and use it in GitHub Desktop.
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 | |
for ($i =1; $i < 12; $i++ ) { | |
echo "/remind #channel to BLABLABLA on " . getFriday($i, 2019) . " 16:30 \n"; | |
} | |
function getFriday($m,$y) { | |
$dateString = "$y-$m-01"; | |
$newdate = date("Y-m-t", strtotime($dateString)); | |
$lastworkingday = date('l', strtotime($newdate)); | |
if($lastworkingday == "Saturday") { | |
$newdate = date ( 'Y-m-j', strtotime ('-2 day', strtotime($newdate))); | |
} | |
elseif($lastworkingday == "Sunday") { | |
$newdate = date ( 'Y-m-j', strtotime ('-2 day', strtotime($newdate))); | |
} | |
return date('Y-m-j', strtotime($newdate)); | |
} | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment