phattarachai/thaidate

A Laravel, PHP package for thaidate() function
47,052 12
Install
composer require phattarachai/thaidate
Latest Version:v13.0.0
PHP:^8.3
License:MIT
Last Updated:Sep 28, 2026
Links: GitHub  ·  Packagist
Maintainer: phatchai

Thaidate

Latest Version on Packagist Tests Code Style PHP Version Laravel Version Total Downloads

Display dates in Thai — as a thaidate() helper and a Carbon ->thaidate() macro, with Buddhist-era years and Thai month/day names.

Installation

composer require phattarachai/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-02-25')->thaidate();
// 25 กุมภาพันธ์ 2564

Carbon::parse('2021-02-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 

Static analysis

The ->thaidate() macro is registered at runtime, which PHPStan can't see on its own. This package ships the PHPStan support to fix that — ->thaidate() resolves with no "undefined method" errors and no per-project baseline entries. It activates automatically in any project using phpstan/extension-installer:

composer require --dev phpstan/extension-installer

ผู้พัฒนา

🙋‍♂️ สวัสดีครับ ผมอ๊อฟนะครับ เป็น Full Stack Web Developer รับ Implement งาน Project ทางด้าน Web Application สำหรับองค์กร ธุรกิจ SME ส่วนงานราชการและบริษัทขนาดใหญ่ครับ
https://phattarachai.dev

line: phat-chai

License

The MIT License (MIT)

Related Packages

doctrine/dbal

Powerful PHP database abstraction layer (DBAL) with many features for database s...

641,106,524 9,700
laravel/framework

The Laravel Framework.

593,882,149 34,959
laravel/tinker

Powerful REPL for the Laravel framework.

502,645,077 7,441
laravel/serializable-closure

Laravel Serializable Closure provides an easy and secure way to serialize closur...

418,291,778 609
nunomaduro/collision

Cli error handling for console/command-line PHP applications.

394,964,158 4,660

Version History

Version Released PHP Laravel License
v13.0.0 ^8.3 ^12.0|^13.0 MIT
12.1 ^7.3|^8.0 MIT
1.2.1 ^7.3|^8.0 MIT
1.2.0 ^7.3|^8.0 MIT
1.1.2 ^7.3|^8.0 MIT