How to use PHP & Convert Date/Time This function will be using PHP and using function Convert Date/Time
ShotDev Focus:
- PHP & Convert Date/Time
Example
php_date_convert.php
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<?php
function DateThai($strDate)
{
$strYear = date("Y",strtotime($strDate))+543;
$strMonth = date("n",strtotime($strDate));
$strDay = date("j",strtotime($strDate));
$strHour = date("H",strtotime($strDate));
$strMinute = date("i",strtotime($strDate));
$strSeconds = date("s",strtotime($strDate));
$strMonthCut = Array("","ม.ค.","ก.พ.","มี.ค.","เม.ย.","พ.ค.","มิ.ย.","ก.ค.","ส.ค.","ก.ย.","ต.ค.","พ.ย.","ธ.ค.");
$strMonthThai = $strMonthCut[$strMonth];
return "$strDay $strMonthThai $strYear, $strHour:$strMinute";
}
$strDate = "2010-08-14 13:42:44";
echo "Convert to Thai format : ".DateThai($strDate);
?>
</body>
</html>
Create a php file and save to path root-path/myphp/
Run
http://localhost/myphp/php_date_convert.php
Screenshot


