Skip to content

Instantly share code, notes, and snippets.

@pmgupte
Last active October 6, 2016 07:03
Show Gist options
  • Save pmgupte/5796298 to your computer and use it in GitHub Desktop.
Save pmgupte/5796298 to your computer and use it in GitHub Desktop.
PHP function to check if today’s day occurs for the last time in current month.
<?php
/**
* Copyright (C) 2016 Prabhas Gupte
*
* This is free script: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This script is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should also see <http://www.gnu.org/licenses/gpl.txt>
*/
function is_last_occurance($day) {
$month_this_day = date("n");
$month_next_day = date("n", strtotime("next $day"));
return $month_this_day!=$month_next_day?true:false;
}// is_last_occurance
is_last_occurance('Mon');
is_last_occurance('Sunday');
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment