|
|
|
แปลงวันที่จาก ค.ศ. เป็น พ.ศ.ได้ แต่พอจะแปลงกลับเป็น ค.ศ. ไม่ได้ |
|
|
|
|
|
|
|
Code (PHP)
<?
function DateThai($datetime)
{
$strYear = date("Y",strtotime($datetime))+543;
$strMonth= date("n",strtotime($datetime));
$strDay= date("j",strtotime($datetime));
$strHour= date("H",strtotime($datetime));
$strMinute= date("i",strtotime($datetime));
$strSeconds= date("s",strtotime($datetime));
$strMonthCut = Array("","01","02","03","04","05","06","07","08","09","10","11","12");
$strMonthThai=$strMonthCut[$strMonth];
return "$strDay/$strMonthThai/$strYear $strHour:$strMinute:$strSeconds";
}
function DateEng($datetime)
{
$strYear = date("Y",strtotime($datetime))-543;
$strMonth= date("n",strtotime($datetime));
$strDay= date("j",strtotime($datetime));
$strHour= date("H",strtotime($datetime));
$strMinute= date("i",strtotime($datetime));
$strSeconds= date("s",strtotime($datetime));
$strMonthCut = Array("","01","02","03","04","05","06","07","08","09","10","11","12");
$strMonthThai=$strMonthCut[$strMonth];
return "$strYear-$strMonthThai-$strDay $strHour:$strMinute:$strSeconds";
}
echo $datetime_now = date("Y-m-d H:i:s");
echo "<br>";
echo $datethai = DateThai($datetime_now);
echo "<br>";
echo DateEng($datethai);
?>
Tag : PHP, HTML/CSS, JavaScript
|
|
|
|
|
|
Date :
2017-02-27 14:08:01 |
By :
eos7d |
View :
5032 |
Reply :
4 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|