pitchayakit / laravel-buddhist-era
Laravel package that makes Carbon's translatedFormat() show the Buddhist Era year (CE + 543) in Thai and the Gregorian year in every other locale.
Package info
github.com/pitchayakit/laravel-buddhist-era
pkg:composer/pitchayakit/laravel-buddhist-era
Requires
- php: ^8.2
- illuminate/support: ^12.0 || ^13.0
- nesbot/carbon: ^3.8
Requires (Dev)
- livewire/livewire: ^3.6 || ^4.0
- orchestra/testbench: ^10.0 || ^11.0
- phpunit/phpunit: ^11.5 || ^12.0 || ^13.0
Suggests
- livewire/livewire: Dates in public Livewire properties keep working; enable() registers the class with Livewire.
Provides
None
Conflicts
None
Replaces
None
README
A Laravel package that makes Carbon's translatedFormat() show the Buddhist Era year (CE + 543) when the locale is Thai, and the Gregorian year in every other locale. Built for Laravel apps that serve more than one language.
Requires Laravel 12 or 13. It does not work with Carbon outside Laravel.
Install
composer require pitchayakit/laravel-buddhist-era
That is all. Laravel discovers the package's service provider, so there is nothing to register or configure.
Use
Nothing changes at the call site:
$model->created_at->translatedFormat('d M Y'); // th: 14 พ.ย. 2569 en: 14 Nov 2026 $model->created_at->translatedFormat('l j F Y'); // th: เสาร์ 14 พฤศจิกายน 2569 $model->created_at->format('Y-m-d'); // 2026-11-14 in every locale
- The date follows the app locale, so there is no need to check
app()->getLocale()or call->locale(). Y,yandoare converted in Thai; an escaped\Ystays literal.- Only the year is converted. The date is never shifted, so leap days and weekdays stay correct.
format()is untouched, so database values and machine formats stay Gregorian.
Which dates are covered
The package makes Laravel create its date class wherever it builds a date: model date casts, now(), today() and the Date facade.
A date built with Carbon::parse() or Carbon::now() directly is a plain Carbon and stays Gregorian. Use Date::parse() instead.
Livewire is supported: the package registers the class with Livewire so dates in public properties survive between requests.
If your app already sets its own date class with Date::use(), that choice wins and this package stays inactive.