Skip to content

Instantly share code, notes, and snippets.

@nathaningram
Created July 27, 2023 19:05
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 nathaningram/d2b7e94bc7860410772761203fdc5e23 to your computer and use it in GitHub Desktop.
Save nathaningram/d2b7e94bc7860410772761203fdc5e23 to your computer and use it in GitHub Desktop.
Third Tuesday from Office Hours
function find_next_third_tuesday() {
$date = new DateTime();
$date->modify('first day of this month');
while ($date->format('D') != 'Tue') {
$date->modify('next day');
}
$date->modify('+2 weeks');
if($date < new DateTime()) {
$date->modify('first day of next month');
while ($date->format('D') != 'Tue') {
$date->modify('next day');
}
$date->modify('+2 weeks');
}
return $date->format('l, F j, Y');
}
function show_next_third_tuesday(){
$next_third_tuesday = find_next_third_tuesday();
$output = $next_third_tuesday . " at 11:30am";
return $output;
}
add_shortcode('next_third_tuesday', 'show_next_third_tuesday');
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment