Forum Moderators: coopster
How would I get the next 2 week period (closest to current date)?
Periods - 1st - 15th each month, 16th - end of month.
[php]
$now = time();
$currentDate = date("Y-m-d H:i:s", $now);
$previous_period = ? // Y-m-d H:i:s
$next_period= ? // Y-m-d H:i:s
[/php]
example output would be:
today = 21st August 2007
Prev Period = 15th August 2007
Next Period = 1st September
[php]
// Set date / time variables
$thisMonth = date("F", $now); // example - August
$next_Month = date("F", strtotime("+1 months")); // example - September
$thisYear = date("Y", $now); // example - 2007
// get pay period and run query
if ($thisDay < 15)
{
$PayStartDay= "01"; // day of this month
$PayEndDay = "14"; // day of this month
$query = " select * from tablename WHERE sale_date BETWEEN $PayStartDay - $thisMonth - $thisYear ";
// run rest of code here
} else {
$PayStartDay= "15"; // day of this month
$PayEndDay = "31"; // day of this month
$query = " select * from tablename WHERE sale_date BETWEEN $PayStartDay - $thisMonth - $thisYear ";
// run rest of code here
}
[/php]