afiqiqmal / malaysiaholiday
to get all holidays date in malaysia
Requires
- php: ^8.2
- symfony/browser-kit: ^7.4 || ^8.0
- symfony/css-selector: ^7.4 || ^8.0
- symfony/http-client: ^7.4 || ^8.0
Requires (Dev)
- phpunit/phpunit: ^11.5 || ^12.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
Parsing Malaysian Public Holidays
Holidays based on country
If you want the list of holidays based on countries, you may refer here https://github.com/afiqiqmal/country-holiday
How to Use ✨
Declare
$holiday = new MalaysiaHoliday; MalaysiaHoliday::make(); app(MalaysiaHoliday::class); // if bound with laravel refer here - https://laravel.com/docs/13.x/container#contextual-binding
Holidays in current year
$holiday = new MalaysiaHoliday; // MalaysiaHoliday::make() $holiday->fromAllState()->get(); MalaysiaHoliday::make()->fromAllState()->get();
Holidays in specific years
$holiday = new MalaysiaHoliday; $holiday->fromAllState(2017)->get(); $holiday->fromAllState([2017, 2019])->get(); $holiday->fromAllState()->ofYear(2017)->get(); MalaysiaHoliday::make()->fromAllState()->ofYear(2017)->get();
Holidays by region
$holiday = new MalaysiaHoliday; $holiday->fromState("Selangor")->get(); $holiday->fromState(["Selangor","Malacca"])->get();
Holidays by region and year
$holiday = new MalaysiaHoliday; $holiday->fromState("Selangor","2017")->get(); $holiday->fromState("Selangor", [2017, 2019])->get(); $holiday->fromState(["Selangor","Malacca"], [2017, 2019])->get(); $holiday->fromState(["Selangor","Malacca"])->ofYear([2017, 2019])->get();
Group and filter results
$holiday = new MalaysiaHoliday; $holiday->fromAllState()->groupByMonth()->get(); $holiday->fromAllState()->filterByMonth("January")->get(); //date('F')
School Holidays 🏫
Malaysia school holidays (Kumpulan A & Kumpulan B), including term and festive holidays
MalaysiaSchoolHoliday::make()->get(); // all groups, current year MalaysiaSchoolHoliday::make()->fromState("Selangor")->get(); MalaysiaSchoolHoliday::make()->fromState(["Selangor", "Kedah"])->get(); MalaysiaSchoolHoliday::make()->ofYear(2026)->get();
Data is taken from publicholidays.com.my (current academic year only, with festival names). Other years fall back to calendarmalaysia.com (2025 onwards, names in Malay such as
CUTI PENGGAL 1/TAMBAHAN CUTI PERAYAAN). Thesourcekey shows which one was used. A year with no data returnsstatus: falsewith a message.
Sample
{
"status":true,
"year":2026,
"source":"https://publicholidays.com.my/school-holidays/",
"data":[
{
"regional":"Selangor",
"group":"Kumpulan B",
"collection":[
{
"name":"Term 1 Holidays",
"start_date":"2026-03-21",
"end_date":"2026-03-29",
"start_day":"Saturday",
"end_day":"Sunday",
"total_days":9,
"is_holiday":true,
"type":"Term Holiday",
"states":["Johor", "Kuala Lumpur", "..."]
}
]
}
],
"error_messages":[]
}
type is one of School Session (first day of school), Term Holiday or Festive Holiday.
Requirements
- PHP 8.2 - 8.5
- Symfony 7.4 / 8.x components
- Framework agnostic — works with Laravel 11, 12 and 13
To install
run
composer require afiqiqmal/malaysiaholiday
Sample
{
"status":true,
"data":[
{
"regional":"Selangor",
"collection":[
{
"year":2019,
"data":[
{
"day":"Tuesday",
"date":"2019-01-01",
"date_formatted":"01 January 2019",
"month":"January",
"name":"New Year's Day",
"description":"Regional Holiday",
"is_holiday":true,
"type":"Regional Holiday",
"type_id":4
},
{
"day":"Monday",
"date":"2019-01-21",
"date_formatted":"21 January 2019",
"month":"January",
"name":"Thaipusam",
"description":"Regional Holiday",
"is_holiday":true,
"type":"Regional Holiday",
"type_id":4
}
]
}
]
},
{
"regional":"Johor",
"collection":[
{
"year":2019,
"data":[
{
"day":"Monday",
"date":"2019-01-21",
"date_formatted":"21 January 2019",
"month":"January",
"name":"Thaipusam",
"description":"Regional Holiday",
"is_holiday":true,
"type":"Regional Holiday",
"type_id":4
}
]
}
]
}
],
"developer":{
"name":"Hafiq",
"email":"hafiqiqmal93@gmail.com",
"github":"https://github.com/afiqiqmal"
}
}
Source 📅
Scraped from - http://www.officeholidays.com/countries/malaysia
School holidays scraped from - https://publicholidays.com.my/school-holidays/ and https://calendarmalaysia.com
MIT Licence
Copyright © 2017 @afiqiqmal
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the “Software”), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED “AS IS”, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.