1: <?php
2: /*
3: *
4: * @author Vee W.
5: * @license http://opensource.org/licenses/MIT
6: *
7: */
8:
9:
10: /**
11: * Thai date use date() function.
12: *
13: * @param string $format The format as same as PHP date function format. See http://php.net/manual/en/function.date.php
14: * @param integer $timestamp The optional timestamp is an integer Unix timestamp.
15: * @param boolean $buddhist_era Use Buddhist era? set to true to use that or false not to use.
16: * @return string Return the formatted date/time string.
17: */
18: function thaidate($format, $timestamp = '', $buddhist_era = true)
19: {
20: if (!is_bool($buddhist_era)) {
21: $buddhist_era = true;
22: }
23:
24: $thaidate = new \Rundiz\Thaidate\Thaidate();
25: $thaidate->buddhist_era = $buddhist_era;
26: return $thaidate->date($format, $timestamp);
27: }// thaidate
28:
29:
30: /**
31: * Thai date use strftime() function.
32: *
33: * @param string $format The format as same as PHP date function format. See http://php.net/manual/en/function.strftime.php
34: * @param integer $timestamp The optional timestamp is an integer Unix timestamp.
35: * @param boolean $buddhist_era Use Buddhist era? set to true to use that or false not to use.
36: * @param string $locale The locale that will be use in setlocale() function. See http://php.net/setlocale
37: * @return string Return the formatted date/time string.
38: */
39: function thaistrftime($format, $timestamp = '', $buddhist_era = true, $locale = 'th')
40: {
41: if ($locale == null) {
42: $locale = 'th';
43: }
44:
45: if (!is_bool($buddhist_era)) {
46: $buddhist_era = true;
47: }
48:
49: $thaidate = new \Rundiz\Thaidate\Thaidate();
50: $thaidate->buddhist_era = $buddhist_era;
51: $thaidate->locale = $locale;
52: return $thaidate->strftime($format, $timestamp);
53: }// thaistrftime