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'))); }
/** * Thai date use date() function. * * @param string $format The format as same as PHP date function format. See http://php.net/manual/en/function.date.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. * @return string Return the formatted date/time string. */ function thaidate($format, $timestamp = '', $buddhist_era = true) { if (!is_bool($buddhist_era)) { $buddhist_era = true; } $thaidate = new \Rundiz\Thaidate\Thaidate(); $thaidate->buddhist_era = $buddhist_era; return $thaidate->date($format, $timestamp); }