Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save MrSam/37cca0641d4a036ca0242e754c9b0c47 to your computer and use it in GitHub Desktop.
Save MrSam/37cca0641d4a036ca0242e754c9b0c47 to your computer and use it in GitHub Desktop.
<?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