490 lines
15 KiB
PHP
490 lines
15 KiB
PHP
<?php
|
|
//--------------------------------------ฟังก์ชันแปลงวันเป็นภาษาไทยแบบเต็ม------------------------------------------------//
|
|
function thai_date($date)
|
|
{
|
|
list($year, $month, $day) = explode('-', $date);
|
|
if ($day < 10) {
|
|
$day = substr($day, 1, 1);
|
|
}
|
|
|
|
$thMonth = array("ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.");
|
|
if ($month < 10) {
|
|
$month = substr($month, 1, 1);
|
|
}
|
|
|
|
$year += 543;
|
|
|
|
return $day . " " . $thMonth[$month - 1] . " " . $year;
|
|
}
|
|
//---------------------------------ฟังก์ชันแปลงวันเป็นภาษาไทยแบบเต็ม-----------------------------------------------------//
|
|
|
|
|
|
//--------------------------------------ฟังก์ชันแปลงเดือนเป็นภาษาไทยแบบเต็ม------------------------------------------------//
|
|
function thai_month($date)
|
|
{
|
|
list($year, $month, $day) = explode('-', $date);
|
|
if ($day < 10) {
|
|
$day = substr($day, 1, 1);
|
|
}
|
|
|
|
$thMonth = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
|
|
if ($month < 10) {
|
|
$month = substr($month, 1, 1);
|
|
}
|
|
|
|
$year += 543;
|
|
|
|
return $thMonth[$month - 1] . " " . $year;
|
|
}
|
|
//---------------------------------ฟังก์ชันแปลงเดือนเป็นภาษาไทยแบบเต็ม-----------------------------------------------------//
|
|
|
|
//--------------------------------------ฟังก์ชันแปลงวันเป็นภาษาไทย2------------------------------------------------//
|
|
function thai_date2($date)
|
|
{
|
|
list($year, $month, $day) = explode('-', $date);
|
|
|
|
$year += 543;
|
|
|
|
return $day . "-" . $month . "-" . $year;
|
|
}
|
|
|
|
function thai_date3($date)
|
|
{
|
|
list($year, $month, $day) = explode('-', $date);
|
|
|
|
return $day . "-" . $month . "-" . $year;
|
|
}
|
|
|
|
function thai_date5($date)
|
|
{
|
|
list($day, $month, $year) = explode('-', $date);
|
|
if ($day < 10) {
|
|
$day = substr($day, 1, 1);
|
|
}
|
|
|
|
$thMonth = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
|
|
if ($month < 10) {
|
|
$month = substr($month, 1, 1);
|
|
}
|
|
|
|
return $day . " " . $thMonth[$month - 1] . " พ.ศ. " . $year;
|
|
}
|
|
|
|
function thai_date6($date)
|
|
{
|
|
list($year, $month, $day) = explode('-', $date);
|
|
if ($day < 10) {
|
|
$day = substr($day, 1, 1);
|
|
}
|
|
|
|
$thMonth = array("ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.");
|
|
if ($month < 10) {
|
|
$month = substr($month, 1, 1);
|
|
}
|
|
|
|
$year = $year + 543;
|
|
|
|
return $day . " " . $thMonth[$month - 1] . " " . $year;
|
|
}
|
|
|
|
function thai_date7($date)
|
|
{
|
|
list($year, $month, $day) = explode('-', $date);
|
|
if ($day < 10) {
|
|
$day = substr($day, 1, 1);
|
|
}
|
|
|
|
$thMonth = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
|
|
if ($month < 10) {
|
|
$month = substr($month, 1, 1);
|
|
}
|
|
$year = $year + 543;
|
|
|
|
return "วันที่ " . $day . " " . $thMonth[$month - 1] . " พ.ศ. " . $year;
|
|
}
|
|
|
|
function thai_date8($date)
|
|
{
|
|
list($day, $month, $year) = explode('-', $date);
|
|
if ($day < 10) {
|
|
$day = substr($day, 1, 1);
|
|
}
|
|
|
|
$thMonth = array("ม.ค.", "ก.พ.", "มี.ค.", "เม.ย.", "พ.ค.", "มิ.ย.", "ก.ค.", "ส.ค.", "ก.ย.", "ต.ค.", "พ.ย.", "ธ.ค.");
|
|
if ($month < 10) {
|
|
$month = substr($month, 1, 1);
|
|
}
|
|
|
|
return $day . " " . $thMonth[$month - 1] . " " . $year;
|
|
}
|
|
|
|
function novel_date1($date)
|
|
{
|
|
list($year, $month, $day) = explode('-', $date);
|
|
|
|
return $day . "/" . $month . "/" . $year;
|
|
}
|
|
|
|
function thai_date9($date)
|
|
{
|
|
list($year, $month, $day) = explode('-', $date);
|
|
|
|
$year += 543;
|
|
|
|
return $day . "/" . $month . "/" . $year;
|
|
}
|
|
//---------------------------------ฟังก์ชันแปลงวันเป็นภาษาไทย2-----------------------------------------------------//
|
|
|
|
//--------------------------------------ฟังก์ชันแปลงวันเป็นรูปแบบของ mysql------------------------------------------------//
|
|
function mysql_date1($date)
|
|
{
|
|
list($day, $month, $year) = explode('-', $date);
|
|
|
|
switch ($month) {
|
|
case "ม.ค.":
|
|
$thMonth = "01";
|
|
break;
|
|
case "ก.พ.":
|
|
$thMonth = "02";
|
|
break;
|
|
case "มี.ค.":
|
|
$thMonth = "03";
|
|
break;
|
|
case "เม.ย.":
|
|
$thMonth = "04";
|
|
break;
|
|
case "พ.ค.":
|
|
$thMonth = "05";
|
|
break;
|
|
case "มิ.ย.":
|
|
$thMonth = "06";
|
|
break;
|
|
case "ก.ค.":
|
|
$thMonth = "07";
|
|
break;
|
|
case "ส.ค.":
|
|
$thMonth = "08";
|
|
break;
|
|
case "ก.ย.":
|
|
$thMonth = "09";
|
|
break;
|
|
case "ต.ค.":
|
|
$thMonth = "10";
|
|
break;
|
|
case "พ.ย.":
|
|
$thMonth = "11";
|
|
break;
|
|
case "ธ.ค.":
|
|
$thMonth = "12";
|
|
break;
|
|
}
|
|
|
|
$year = $year - 543;
|
|
|
|
return $year . "-" . $thMonth . "-" . $day;
|
|
}
|
|
|
|
function mysql_date2($date)
|
|
{
|
|
list($null, $day, $month, $year) = explode('-', $date);
|
|
|
|
switch ($month) {
|
|
case "ม.ค.":
|
|
$thMonth = "01";
|
|
break;
|
|
case "ก.พ.":
|
|
$thMonth = "02";
|
|
break;
|
|
case "มี.ค.":
|
|
$thMonth = "03";
|
|
break;
|
|
case "เม.ย.":
|
|
$thMonth = "04";
|
|
break;
|
|
case "พ.ค.":
|
|
$thMonth = "05";
|
|
break;
|
|
case "มิ.ย.":
|
|
$thMonth = "06";
|
|
break;
|
|
case "ก.ค.":
|
|
$thMonth = "07";
|
|
break;
|
|
case "ส.ค.":
|
|
$thMonth = "08";
|
|
break;
|
|
case "ก.ย.":
|
|
$thMonth = "09";
|
|
break;
|
|
case "ต.ค.":
|
|
$thMonth = "10";
|
|
break;
|
|
case "พ.ย.":
|
|
$thMonth = "11";
|
|
break;
|
|
case "ธ.ค.":
|
|
$thMonth = "12";
|
|
break;
|
|
}
|
|
|
|
$year = $year - 543;
|
|
|
|
return $year . "-" . $thMonth . "-" . $day;
|
|
}
|
|
|
|
function mysql_date3($date)
|
|
{
|
|
@list($day, $month, $year) = @explode('-', $date);
|
|
|
|
return $year . "-" . $month . "-" . $day;
|
|
}
|
|
//--------------------------------ฟังก์ชันแปลงวันเป็นรูปแบบของ mysql------------------------------------------------------//
|
|
|
|
//--------------------------------------ฟังก์ชันแบ่งช่วงของวัน------------------------------------------------//
|
|
function explode_date1($date)
|
|
{
|
|
list($date1, $date2) = explode('-', $date);
|
|
return mysql_date1($date1);
|
|
}
|
|
function explode_date2($date)
|
|
{
|
|
list($date1, $date2) = explode('-', $date);
|
|
$new_date2 = mysql_date2($date2);
|
|
if ($new_date2 == "-543--") {
|
|
echo "";
|
|
} else {
|
|
return $new_date2;
|
|
}
|
|
}
|
|
//---------------------------------ฟังก์ชันแบ่งช่วงของวัน-----------------------------------------------------//
|
|
|
|
|
|
//--------------------------------------ฟังก์ชันแปลงวันเป็นรูปแบบเลขที่ใบสมัคร------------------------------------------------//
|
|
function code_date($date)
|
|
{
|
|
list($year, $month, $day) = explode('-', $date);
|
|
|
|
$Month = $month;
|
|
|
|
$year += 543;
|
|
|
|
$sYear = substr($year, 2, 2);
|
|
|
|
return $sYear . $day . $Month;
|
|
}
|
|
//---------------------------------ฟังก์ชันแปลงวันเป็นรูปแบบเลขที่ใบสมัคร-----------------------------------------------------//
|
|
|
|
//--------------------------------------ฟังก์ชันแยกชื่อ-นามสกุลไฟล์------------------------------------------------//
|
|
function explode_filename($filename)
|
|
{
|
|
list($name, $ext) = explode('.', $filename);
|
|
|
|
return $name;
|
|
}
|
|
|
|
function explode_extname($filename)
|
|
{
|
|
list($name, $ext) = explode('.', $filename);
|
|
|
|
return $ext;
|
|
}
|
|
//---------------------------------ฟังก์ชันแยกชื่อ-นามสกุลไฟล์-----------------------------------------------------//
|
|
|
|
//--------------------------------------ฟังก์ชันแบ่งชื่อ------------------------------------------------//
|
|
function split_fname($name)
|
|
{
|
|
list($fname, $lname) = explode(' ', $name);
|
|
|
|
return $fname;
|
|
}
|
|
function split_lname($name)
|
|
{
|
|
list($fname, $lname) = explode(' ', $name);
|
|
|
|
return $lname;
|
|
}
|
|
//---------------------------------ฟังก์ชันแบ่งชื่อ-----------------------------------------------------//
|
|
|
|
//--------------------------------------ฟังก์ชันแปลงวันเวลาเป็นวัน------------------------------------------------//
|
|
function datetime_to_date($date)
|
|
{
|
|
list($date1, $time) = explode(' ', $date);
|
|
list($year, $month, $day) = explode('-', $date1);
|
|
|
|
$year += 543;
|
|
|
|
return $day . "-" . $month . "-" . $year;
|
|
}
|
|
function datetime_to_date2($date)
|
|
{
|
|
list($date1, $time) = explode('-', $date);
|
|
|
|
return $date1;
|
|
}
|
|
//---------------------------------ฟังก์ชันแปลงวันเวลาเป็นวัน-----------------------------------------------------//
|
|
|
|
//--------------------------------------ฟังก์ชันแปลงวันเวลาเป็นเวลา------------------------------------------------//
|
|
function datetime_to_time($date)
|
|
{
|
|
list($date1, $time) = explode(' ', $date);
|
|
|
|
list($hh, $mm, $ss) = explode(':', $time);
|
|
|
|
return $hh . ":" . $mm;
|
|
}
|
|
//---------------------------------ฟังก์ชันแปลงวันเวลาเป็นเวลา-----------------------------------------------------//
|
|
|
|
//------------------------ตัดคำ----------------------------------------------------//
|
|
|
|
//------------------------------ฟังก์ชั่นตั้งชื่อไฟล์จากวันเวลา------------------------------------------------//
|
|
function gen_filename($date)
|
|
{
|
|
list($date1, $time) = explode(' ', $date);
|
|
list($year, $month, $day) = explode('-', $date1);
|
|
list($hh, $mm, $ss) = explode(':', $time);
|
|
|
|
$year += 543;
|
|
$year2 = substr($year, 2, 2);
|
|
|
|
return $year2 . "" . $month . "" . $day . "" . $hh . "" . $mm . "" . $ss;
|
|
}
|
|
//---------------------------------ฟังก์ชันแปลงวันเวลาเป็นเวลา-----------------------------------------------------//
|
|
|
|
//------------------------ตัดคำ----------------------------------------------------//
|
|
function cutStr($str, $maxChars = '', $holder = '')
|
|
{
|
|
|
|
if (strlen($str) > $maxChars) {
|
|
$str = iconv_substr($str, 0, $maxChars, "UTF-8") . $holder;
|
|
}
|
|
return $str;
|
|
}
|
|
|
|
//--------------------------------------ฟังก์ชันแยกเดือน-ปี------------------------------------------------//
|
|
function showDate($today)
|
|
{
|
|
list($year, $month, $date) = explode('-', $today);
|
|
|
|
return $date;
|
|
}
|
|
|
|
function showDate2($today)
|
|
{
|
|
list($year, $month, $date) = explode('-', $today);
|
|
|
|
return $date;
|
|
}
|
|
|
|
function showMonth($today)
|
|
{
|
|
list($year, $month, $date) = explode('-', $today);
|
|
|
|
return $month;
|
|
}
|
|
|
|
function showMonth2($today)
|
|
{
|
|
list($year, $month, $date) = explode('-', $today);
|
|
|
|
return $month;
|
|
}
|
|
|
|
function showYear($today, $date)
|
|
{
|
|
list($year, $month, $date) = explode('-', $today);
|
|
|
|
return $year;
|
|
}
|
|
|
|
function showYear2($today, $date)
|
|
{
|
|
list($year, $month, $date) = explode('-', $today);
|
|
|
|
return $year;
|
|
}
|
|
|
|
function showAll($today)
|
|
{
|
|
list($year, $month, $date) = explode('-', $today);
|
|
|
|
$thMonth = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
|
|
if ($month < 10) {
|
|
$month = substr($month, 1, 1);
|
|
}
|
|
|
|
$year += 543;
|
|
return $thMonth[$month - 1] . " พ.ศ. " . $year;
|
|
}
|
|
|
|
function showAll2($today)
|
|
{
|
|
list($year, $month, $date) = explode('-', $today);
|
|
|
|
$thMonth = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
|
|
if ($month < 10) {
|
|
$month = substr($month, 1, 1);
|
|
}
|
|
|
|
$year += 543;
|
|
return $date . " " . $thMonth[$month - 1] . " พ.ศ. " . $year;
|
|
}
|
|
|
|
function typeFile($name)
|
|
{
|
|
list($f, $l) = explode('.', $name);
|
|
|
|
return $l;
|
|
}
|
|
|
|
//--------------------------------------ฟังก์ชันแยกเดือน-ปี------------------------------------------------//
|
|
|
|
//--------------------------------------ฟังก์ชันแยกชื่อ-นามสกุล------------------------------------------------//
|
|
function explode_fname($data)
|
|
{
|
|
list($fname, $lname) = explode(' ', $data);
|
|
|
|
return $fname;
|
|
}
|
|
|
|
function explode_lname($data)
|
|
{
|
|
list($fname, $lname) = explode(' ', $data);
|
|
|
|
return $lname;
|
|
}
|
|
//---------------------------------ฟังก์ชันแยกชื่อ-นามสกุล-----------------------------------------------------//
|
|
|
|
//------------------ วันนี้ แยก วัน เดือน ปี -------------------------------------
|
|
|
|
function today_date($date)
|
|
{
|
|
list($year, $month, $day) = explode('-', $date);
|
|
if ($day < 10) {
|
|
$day = substr($day, 1, 1);
|
|
}
|
|
|
|
return $day;
|
|
}
|
|
|
|
function today_month($date)
|
|
{
|
|
list($year, $month, $day) = explode('-', $date);
|
|
|
|
$thMonth = array("มกราคม", "กุมภาพันธ์", "มีนาคม", "เมษายน", "พฤษภาคม", "มิถุนายน", "กรกฎาคม", "สิงหาคม", "กันยายน", "ตุลาคม", "พฤศจิกายน", "ธันวาคม");
|
|
if ($month < 10) {
|
|
$month = substr($month, 1, 1);
|
|
}
|
|
|
|
|
|
return $thMonth[$month - 1];
|
|
}
|
|
|
|
function today_year($date)
|
|
{
|
|
list($year, $month, $day) = explode('-', $date);
|
|
|
|
$year = $year + 543;
|
|
|
|
return $year;
|
|
}
|