| px | top | add code | search | signup | login | help |
<?
///////////////////////////////////////////////////////////////
//Class Show Thai date v1.0
// wrote by , Mr.Satit Phermsawang Aug, 2001
//Contact: satit@wimol.ac.th
//
// Please feel free to modify. and let me know .
//
///////////////////////////////////////////////////////////////
// Ex: $showdate = new TDconv(\"dd-mm-yy\");
// echo $showdate->show_date ;
///////////////////////////////////////////////////////////////
//define class for Convert English date to Thai date.
class TDConv
{
/*
** properties
*/
var $d; //day ex. 1-31
var $dd; //day in week ex. monday - sunday
var $mmm; //month in year ex. January or Jan
var $yyy; //present year ex. 2001 or 2544
var $show_date; // Complete Date ex. 23 jun 1963
/*
** methods
*/
function TDConv($dateType)
{
$chkd =date(\"j\");
$this->d = date(\"j\") ; //show 1 - 31
$this->yyy = date(\"Y\")+543 ;
switch ($dateType) {
case (\"dd-mm-yy\") :
switch (date(\"l\")) {
case \"Monday\" : $this->dd= \"จันทร์\"; break;
case \"Tuesday\" : $this->dd= \"อังคาร\"; break;
case \"Wednesday\" : $this->dd= \"พุธ\"; break;
case \"Thursday\" : $this->dd= \"พฤหัสบดี\"; break;
case \"Friday\" : $this->dd= \"ศุกร์\"; break;
case \"Saturday\" : $this->dd= \"เสาร์\"; break;
default: $this->dd= \"อาทิตย์\"; break;
}
switch(date(\"F\")) {
case \"January\" : $this->mmm = \"มกราคม\"; break;
case \"February\" : $this->mmm = \"กุมภาพันธ์\" ; break;
case \"March\" : $this->mmm = \"มีนาคม\" ; break;
case \"April\" : $this->mmm = \"เมษายน\" ; break;
case \"May\" : $this->mmm = \"พฤษภาคม\" ; break;
case \"June\" : $this->mmm = \"มิถุนายน\" ; break;
case \"July\" : $this->mmm = \"กรกฎาคม\"; break;
case \"August\" : $this->mmm = \"สิงหาคม\" ; break;
case \"September\" : $this->mmm = \"กันยายน\" ; break;
case \"October\" : $this->mmm = \"ตุลาคม\" ; break;
case \"November\" : $this->mmm = \"พฤศจิกายน\" ; break;
default : $this->mmm= \"ธันวาคม\"; break;
}
$this->show_date= $this->dd.\" ที่ \".$this->d.\" \".$this->mmm.\" พ.ศ. \".$this->yyy ;
break ;
case (\"d-m-y\") :
switch(Date(\"F\")) {
case \"January\" : $this->mmm= \"ม.ค.\"; break;
case \"February\" : $this->mmm= \"ก.พ.\" ; break;
case \"March\" : $this->mmm= \"มี.ค.\" ; break;
case \"April\" : $this->mmm= \"เม.ย.\" ; break;
case \"May\" : $this->mmm= \"พ.ค.\" ; break;
case \"Junuary\" : $this->mmm= \"มิ.ย.\" ; break;
case \"July\" : $this->mmm= \"ก.ค.\"; break;
case \"August\" : $this->mmm= \"ส.ค.\" ; break;
case \"September\" : $this->mmm= \"ก.ย.\" ; break;
case \"October\" : $this->mmm= \"ต.ค.\" ; break;
case \"November\" : $this->mmm= \"พ.ย.\" ; break;
default : $this->mmm= \"ธ.ค.\";
}
$this->show_date= $this->d.\" \".$this->mmm.\" \".$this->yyy ;
break ;
default : $this->show_date= $this->d.\" \".$this->mmm.\" \".$this->yyy ;; break;
}
}
}
?>
Comments or questions?
PX is running PHP 5.2.11
Thanks to Miranda Productions for hosting and bandwidth.
Use of any code from PX is at your own risk.