0 Members and 1 Guest are viewing this topic.
<?php$thai_day_arr=array("อาทิตย์","จันทร์","อังคาร","พุธ","พฤหัสบดี","ศุกร์","เสาร์");$thai_month_arr=array( "0"=>"", "1"=>"มกราคม", "2"=>"กุมภาพันธ์", "3"=>"มีนาคม", "4"=>"เมษายน", "5"=>"พฤษภาคม", "6"=>"มิถุนายน", "7"=>"กรกฎาคม", "8"=>"สิงหาคม", "9"=>"กันยายน", "10"=>"ตุลาคม", "11"=>"พฤศจิกายน", "12"=>"ธันวาคม" );function thai_date($time){ global $thai_day_arr,$thai_month_arr; $thai_date_return = $thai_day_arr[date("w",$time)]; $thai_date_return.= "ที่ ".date("j",$time); $thai_date_return.=" เดือน".$thai_month_arr[date("n",$time)]; $thai_date_return.= " พ.ศ.".(date("Yํ",$time)+543); $thai_date_return.= " ".date("H:i",$time)." น."; return $thai_date_return;}// ถ้ามีการเก็บวันที่และเวลาในรูปแบบ timestamp// สามารถนำมาใช้งานในฟังก์ชันได้ดังนี้// $eng=1224562026; กรณีเป็น timestamp$eng_date=time(); // แสดงวันที่ปัจจุบันecho thai_date($eng_date);// ถ้ามีการเก็บวันที่และเวลาในรูปแบบ date// คือ 2008-10-31 ต้องเปลี่ยนเป็น timestamp// ด้วยคำส่ง strtotime("2008-10-31");// แสดงวันที่ 31 เดือน ตุลาคม ปี 2008 แบบภาษาไทย$eng_date=strtotime("2008-10-31"); echo thai_date($eng_date);