Date frequency calculator and public holiday checker.
As per example.php:
Include class file
include('src/datefrequency.php');
Enter a date, count and interval into the nextOccurrence function to get the next occurrence:
//3 months from date
$nextOccurrence = DateFrequency::nextOccurrence('08-05-2018', '3', 'months');
echo '<br>'.$nextOccurrence;
// 2018-08-08
You can also specify the preferred day of the month Eg. "first monday":
//3 months from date and the preferred day of the month
$nextOccurrence = DateFrequency::nextOccurrence('08-05-2018', '3', 'months', 'third wednesday');
echo '<br>'.$nextOccurrence;
// 2018-08-15
To change the format, add it to the parameters:
//custom format
$nextOccurrence = DateFrequency::nextOccurrence('08-05-2018', '3', 'months', 'third wednesday', 'Ymd');
echo '<br>'.$nextOccurrence;
// 20180815
Data utilises the API provided by data.gov.au.
Public Holiday Dataset: https://data.gov.au/dataset/australian-holidays-machine-readable-dataset
Check if date is a public holiday:
//check if date is a public holiday
$isholiday = publicHoliday::isHoliday('13-12-2018');
echo '<br>'.$isholiday;
// false
$isholiday = publicHoliday::isHoliday('25-12-2018');
echo '<br>'.$isholiday;
// true
Get the name of the public holiday:
//get name of public holiday
$holidayName = publicHoliday::holidayName('25-12-2018');
echo '<br>'.$holidayName;
// Christmas Day