chumpol / laravel-thaidate
A Laravel, PHP package for thaidate() function
v1.0.0
2021-06-19 04:57 UTC
Requires
- php: ^7.4|^8.0
Requires (Dev)
- orchestra/testbench: ^6.13
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2025-06-19 13:32:05 UTC
README
Installation
composer require chumpol/laravel-thaidate
thaidate() function
Display date in Thai using the same PHP built-in date() function attributes. The date format is as same as PHP Datetime Format.
Default Format j F Y
:
echo thaidate(); // 25 กุมภาพันธ์ 2564
With PHP Date Format:
echo thaidate('วันlที่ j F พ.ศ.Y เวลา H:i:s'); // results: วันพฤหัสบดีที่ 25 กุมภาพันธ์ พ.ศ.2564 เวลา 23:55:29
Laravel Carbon Usage
You can also use thaidate()
function directly from Laravel carbon instance. It uses Laravel macro feature to add the
functionality as a carbon method.
use Illuminate\Support\Carbon; Carbon::parse('2021-06-25')->thaidate(); // 25 มิถุนายน 2564 Carbon::parse('2021-06-25')->thaidate('D j M y'); // ศ. 25 มิ.ย. 64
This means you can use thaidate() directly from an Eloquent model attributes that is a date attribute as well.
$user->created_at->thaidate(); // 25 มิถุนายน 2564
License
The MIT License (MIT)