File: D:/HostingSpaces/SBogers10/rentman2019.komma.pro/app/Komma/Kms/KmsService.php
<?php
/**
* Short description for the file.
*
* @copyright (c) 2012-2015, Komma
*/
namespace App\Komma\Kms;
class KmsService
{
public function calculateStartAndEndDate($year, $month, $day, $period = 'month')
{
switch ($period) {
case'month':
$start = new \DateTime('first day of '.$year.'-'.$month);
//Fist day of the month
$month++;
//check if the month is now 13
if ($month > 12) {
//yes reset to january and add one year
$month = 1;
$year++;
}
//first day of next month (at 00:00:00)
$end = new \DateTime('first day of '.$year.'-'.($month));
break;
}
return ['start'=> $start, 'end'=> $end];
}
}