 |
|
|
 |
 |
|
<?
#---------------------------------------------------------------------------------------------------------------------------------------------------------------------
#Modify / Update : Çѹ¨Ñ¹·Ãì·Õè 24 µØÅÒ¤Á 2548 àÇÅÒ 1:36 ¹. / Çѹ¨Ñ¹·Ãì·Õè 24 µØÅÒ¤Á 2548 àÇÅÒ 1:36 ¹.
#Description : ºÃÔËÒÃáÅШѴÃٻẺ¢éÍÁÙÅÇѹ·Õè
#---------------------------------------------------------------------------------------------------------------------------------------------------------------------
Class System_Date
{
var $monthfull_en=array(' January ',' February ',' March ',' April ',' May ',' June ',' July ',' August ',' September ',' October ',' November ',' December ');
var $monthfull_th=array('Á¡ÃÒ¤Á','¡ØÁÀҾѹ¸ì','ÁÕ¹Ò¤Á','àÁÉÒ¹','¾ÄÉÀÒ¤Á','ÁԶعÒ¹','¡Ã¡¯Ò¤Á','ÊÔ§ËÒ¤Á','¡Ñ¹ÂÒ¹','µØÅÒ¤Á','¾ÄȨԡÒ¹','¸Ñ¹ÇÒ¤Á');
var $monthshort_en=array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var $monthshort_th=array('Á.¤.','¡.¾.','ÁÕ.¤.','àÁ.Â.','¾.¤.','ÁÔ.Â.','¡.¤.','Ê.¤.','¡.Â.','µ.¤.','¾.Â.','¸.¤.');
var $montnumber=array('1','2','3','4','5','6','7','8','9','10','11','12');
var $monthdisplay=array('01','02','03','04','05','06','07','08','09','10','11','12');
var $datelist=array('00','01','02','03','04','05','06','07','08','09','10','11','12','13','14','15','16','17','18','19','20','21','22','23','24','25','26','27','28','29','30','31');
var $DateShortTh=array('ÍÒ','¨','Í','¾','¾Ä','È','Ê');
var $DateFullTh=array('ÍÒ·ÔµÂì','¨Ñ¹·Ãì','Íѧ¤ÒÃ','¾Ø¸','¾ÄËÑʺ´Õ','ÈØ¡Ãì','àÊÒÃì');
var $CurrentYear,$CurrentMonth,$CurrentDate;
var $temp,$temp1;
var $DateFormat;
var $SignOfDate,$CurrentDateLanguage;
/*
Update : Thu 1 September,2005 23:26 PM
Description : Function System_Date is define current data or time.
*/
function System_Date()
{
global $System_Date_Format,$System_Date_Language;
$this->CurrentYear=date('Y');
$this->CurrentMonth=date('m');
$this->CurrentDate=date('d');
$this->CurrentDateFormat=$System_Date_Format;
$this->CurrentDateLanguage=$System_Date_Language;
}
/*
Update : Thu 1 September,2005 23:27 PM
Description : Function ListAllMonth is make select object for display month
*/
function ListAllMonth($MonthID)
{
$this->temp="";
for($i=0;$i<count($this->monthfull_en);$i++)
{
$this->temp.="<option value=\"".($i+1)."\"";
if($MonthID==$i){
$this->temp.=" selected";
}
$this->temp.=">".$this->monthfull_en[$i]."</option>".chr(13);
}
return $this->temp;
}
/*
Update : Thu 1 September,2005 23:27 PM
Description : List All year.
*/
function ListAllYear($YearID)
{
$start=date('Y')-40;
$stop=date('Y')+40;
for($i=$start;$i<=$stop;$i++)
{
$this->tempyear.="<option value=\"".$i."\" ";
if($YearID==$i)
{
$this->tempyear.= "selected";
}
$this->tempyear.=">".$i."</option>";
}
return $this->tempyear;
}
/*
Update : Thu 1 September,2005 23:29 PM
Description : List All date
*/
function ListAllDate($DateID)
{
for($i=1;$i<=31;$i++)
{
$this->temp.="<option value=\"".$i."\" ";
if($DateID==$i){
$this->temp.="selected";
}
$this->temp.=">".$i."</option>".chr(13);
}
return $this->temp;
}
function DateFormate($DateTime,$Format)
{
if($DateTime=="0000-00-00 00:00:00" || empty($DateTime)) { return "N/A"; }
$myDate = split("00:00:00",$DateTime);
$myTime = explode(" ",$DateTime);
$myDates = split("-",$myDate[0]);
switch($Format)
{
case "ThaiFormat1" : return $this->DateThaiFormat($myDates[2],$myDates[1],$myDates[0]); break;
case "ThaiFormat2" : return $this->DateThaiFormat1($myDates[2],$myDates[1],$myDates[0]); break;
case "ThaiFormat3" : return $this->DateThaiFormat2($myDates[2],$myDates[1],$myDates[0],$myTime[1]); break;
case "ThaiFormat4" : return $this->DateThaiFormat3($myDates[2],$myDates[1],$myDates[0],$myTime[1]); break;
case "ThaiFormat5" : return $this->DateThaiFormat4($myDates[2],$myDates[1],$myDates[0]); break;
case "EngFormat1" : return $this->DateEngFormat1($myDates[2],$myDates[1],$myDates[0]); break;
case "Short" : return $myDate[0]; break;
}
}
function DateEngFormat1($Day,$Month,$Year)
{
// 14/07/2006
return $Day."/".$Month."/".$Year;
}
function DateThaiFormat($Day,$Month,$Year)
{
$this->temp = ($Day*1)." ".$this->monthfull_th[($Month*1)-1]." ".($Year+543);
return $this->temp;
}
# Funciton Name -> DateThaiFormat1
# Function Desc -> ¨Ñ´ÃٻẺÇѹ·ÕèÊÓËÃѺ¿ÍÃìÁá¡é䢢éÍÁÙÅ
function DateThaiFormat1($Day,$Month,$Year)
{
$this->temp="";
$Month = $Month*1;
$Day = $Day*1;
$Year = $Year*1;
$mLocalDate = mktime(0,0,0,$Month,$Day,$Year);
$this->temp = $this->DateShortTh[date("w",$mLocalDate)].".,";
$this->temp.= ($Day*1)."/".($Month*1)."/".($Year+543);
return $this->temp;
}
# Function Name -> DateThaiFormat2
# Function Desc -> ¨Ñ´ÃٻẺÇѹ·ÕèẺä·ÂáÅШѴàÇÅÒ´éǹÐ
function DateThaiFormat2($Day,$Month,$Year,$Time)
{
$Month = $Month*1;
$Day = $Day*1;
$Year = $Year*1;
$mLocalDate = mktime(0,0,0,$Month,$Day,$Year);
$this->temp = "";
$this->temp= "Çѹ".$this->DateFullTh[date("w",$mLocalDate)]." ·Õè ".$this->DateThaiFormat($Day,$Month,$Year)." ".$this->TimeFormat1($Time);
return $this->temp;
}
# Function Name -> DateThaiFormat3
# Function Desc -> ¨Ñ´ÃٻẺÇѹ·ÕèẺä·ÂáÅШѴàÇÅÒ´éǹÐ
function DateThaiFormat3($Day,$Month,$Year,$Time)
{
$this->temp = "";
$this->temp= $this->DateThaiFormat($Day,$Month,$Year)." ".$this->TimeFormat1($Time);
return $this->temp;
}
# Function Name -> DateThaiFormat4
# Function Desc -> ¨Ñ´ÃٻẺÇѹ·ÕèẺä·Â
function DateThaiFormat4($Day,$Month,$Year)
{
$Month = $Month*1;
$Day = $Day*1;
$Year = $Year*1;
$mLocalDate = mktime(0,0,0,$Month,$Day,$Year);
$this->temp = "";
$this->temp= "Çѹ".$this->DateFullTh[date("w",$mLocalDate)]." ·Õè ".$this->DateThaiFormat($Day,$Month,$Year);
return $this->temp;
}
# Function Name -> TimeFormat1
# Function Desc -> ¨Ñ´ÃٻẺàÇÅÒ
function TimeFormat1($Time)
{
list($hour,$min,$sec) = explode(":",$Time);
return "àÇÅÒ ".$hour.":".$min." ¹.";
}
# Function Name -> NextWeek
# Function Desc -> ËÒÇѹ·Õèã¹ÊÑ»´ÒËìµèÍä»
function NextWeek($DateType)
{
strtotime("now");
switch($DateType)
{
case "LastWeek" : return date('Y-m-d h:m:s',strtotime("last sunday")); break;
case "ThisWeek" : return date('Y-m-d h:m:s',strtotime("this sunday")); break;
case "NextWeek" : return date('Y-m-d h:m:s',strtotime("next sunday")); break;
}
}
# Function Name -> ChangeDateFormat1
# Function Desc -> à»ÅÕè¹ÃٻẺÇѹ·Õè¨Ò¡ Í.,01/11/2548 à»ç¹ 0000-00-00 00:00:00
function ChangeDateFormat1($DateFormat)
{
$this->temp = "";
$this->temp = explode(".,",$DateFormat);
$this->temp1 = explode("/",$this->temp[1]);
return ($this->temp1[2]-543)."-".$this->temp1[1]."-".$this->temp1[0]." 00:00:00";
}
}
?>
|
 |
 |
 |
 |
Date :
11 ต.ค. 2549 17:08:32 |
By :
noname |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ช่วยบอกวิธีวางโค้ดหน่อยสิครับ เขียน PHP ไม่ค่อยจะเป็นอ่ะครับ ขอบคุณครับ ไหนๆ ก็ให้โค้ดมาแล้ว ช่วยแนะนำหน่อยดิ ครับ หรือท่านผู้รู้ก็ได้ครับ
|
 |
 |
 |
 |
Date :
11 ต.ค. 2549 17:20:15 |
By :
lufc |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|