Created
July 27, 2023 19:05
-
-
Save nathaningram/d2b7e94bc7860410772761203fdc5e23 to your computer and use it in GitHub Desktop.
Third Tuesday from Office Hours
This file contains 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
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