Created
November 24, 2016 23:58
-
-
Save M4R14/82107d792f69a8ad150fa71cc0a670bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function DateThai($strDate){ | |
| $strMonthCut = Array("", "ม.ค.", "ก.ม.", "มี.ค.","ม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค."); | |
| $inputDate = array( | |
| 'year' => date("Y",strtotime($strDate))+543, | |
| 'month' => date("n",strtotime($strDate)), | |
| 'day' => date("j",strtotime($strDate)), | |
| 'hour' => date("H",strtotime($strDate)), | |
| 'minute' => date("i",strtotime($strDate)), | |
| 'seconds' => date("s",strtotime($strDate)), | |
| 'monthThai' => $strMonthCut[date("n",strtotime($strDate))], | |
| ); | |
| if(isset($strDate)){ | |
| if ($inputDate['hour'] == "00" || $inputDate['hour'] == "0") { | |
| $strNew = $inputDate['day'] ." ". $inputDate['monthThai'] ." ". $inputDate['year']; | |
| } else { | |
| $strNew = $inputDate['day'] ." ". $inputDate['monthThai'] ." ". $inputDate['year'] ." เวลา ". $inputDate['hour'] .":". $inputDate['seconds']; | |
| } | |
| }else { | |
| $strNew = null; | |
| } | |
| return $strNew; | |
| } | |
| ?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment