dixonsatit/yii2-thai-year-formatter
最新稳定版本:0.9.8
Composer 安装命令:
composer require dixonsatit/yii2-thai-year-formatter
包简介
Convert Year to Thai Buddhist Era Year
关键字:
README 文档
README
แปลงค่าวันที่ เป็นปีภาษาไทย สำหรับ Yii framework (Yii 2)
ThaiYearFormatter จำเป็นต้องเปิดการใช้งาน php extension intl ใน php.ini
เปิดไฟล์ php.ini แล้วเปิดใช้งาน ดังนี้
extension=php_intl.dll
[intl]
intl.default_locale =th_TH.UTF-8
; This directive allows you to produce PHP errors when some error
; happens within intl functions. The value is the level of the error produced.
; Default is 0, which does not produce any errors.
;intl.error_level = E_WARNING
หากยังไม่มีให้ติดตั้งที่ server ดูที่นี่
ที่มา http://stackoverflow.com/questions/3191664/list-of-all-locales-and-their-short-codes
การติดตั้ง
composer require --prefer-dist dixonsatit/yii2-thai-year-formatter "*"
หรือเพิ่มที่ ไฟล์ composer.json ในส่วน require
"dixonsatit/yii2-thai-year-formatter": "*"
หลังจากนั้น รันคำสั่ง composer update
การตั้งค่า
'language'=>'th_TH', // เปิดใช้งานภาษาไทย
'components' => [
//...
'thaiFormatter'=>[
'class'=>'dixonsatit\thaiYearFormatter\ThaiYearFormatter',
],
]
การเรียกใช้งาน
เรียกใช้งานผ่าน component thaiFormatter
$time = time(); //$time = '2015-06-03 13:25:17'; echo Yii::$app->thaiFormatter->asDate($time, 'short')."<br>"; echo Yii::$app->thaiFormatter->asDate($time, 'medium')."<br>"; echo Yii::$app->thaiFormatter->asDate($time, 'long')."<br>"; echo Yii::$app->thaiFormatter->asDate($time, 'full')."<br>"; echo Yii::$app->thaiFormatter->asDateTime($time, 'short')."<br>"; echo Yii::$app->thaiFormatter->asDateTime($time, 'medium')."<br>"; echo Yii::$app->thaiFormatter->asDateTime($time, 'long')."<br>"; echo Yii::$app->thaiFormatter->asDateTime($time, 'full')."<br>"; echo Yii::$app->thaiFormatter->asDate($time, 'php:Y-m-d'); echo Yii::$app->thaiFormatter->asDateTime($time, 'php:Y-m-d H:i:s');
ดู php date format ได้ที่นี่ php date format
แสดงผล
25/6/2558
25 มิ.ย. 2558
25 มิถุนายน 2558
วันอาทิตย์ที่ 25 มิถุนายน พ.ศ. 2558
25/6/2558, 9:57
25 มิ.ย. 2558, 9:57:18
25 มิถุนายน 2558, 9 นาฬิกา 57 นาที 18 วินาที GMT+07:00
วันอาทิตย์ที่ 25 มิถุนายน พ.ศ. 2558, 9 นาฬิกา 57 นาที 18 วินาที GMT+07:00
2015-06-24
2015-06-24 05:32:54
统计信息
- 总下载量: 4.66k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 8
- 点击次数: 2
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-06-24