示例#1
0
 public function testThaidateClass()
 {
     $timestamp = 1460619637;
     $Thaidate = new \Rundiz\Thaidate\Thaidate();
     $this->assertEquals('วันพฤหัสบดีที่ 14 เมษายน พ.ศ.2559', $Thaidate->date('วันlที่ j F พ.ศ.Y', $timestamp));
     $this->assertEquals('พฤ. 14 เม.ย. 59', $Thaidate->strftime('%a %d %b %y', $timestamp, true, array('th', 'th_TH.utf8', 'th_TH.UTF8', 'th_TH.utf-8', 'th_TH.UTF-8', 'th_TH', 'th-TH')));
 }
示例#2
0
/**
 * Thai date use strftime() function.
 * 
 * @param string $format The format as same as PHP date function format. See http://php.net/manual/en/function.strftime.php
 * @param integer $timestamp The optional timestamp is an integer Unix timestamp.
 * @param boolean $buddhist_era Use Buddhist era? set to true to use that or false not to use.
 * @param string $locale The locale that will be use in setlocale() function. See http://php.net/setlocale
 * @return string Return the formatted date/time string.
 */
function thaistrftime($format, $timestamp = '', $buddhist_era = true, $locale = 'th')
{
    if ($locale == null) {
        $locale = 'th';
    }
    if (!is_bool($buddhist_era)) {
        $buddhist_era = true;
    }
    $thaidate = new \Rundiz\Thaidate\Thaidate();
    $thaidate->buddhist_era = $buddhist_era;
    $thaidate->locale = $locale;
    return $thaidate->strftime($format, $timestamp);
}