 |
|
เกี่ยวกับฟังชั่นนี้ครับ
Code (PHP)
<?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";
}
?>
แล้วก็ใช้คำสั่งที่ให้ออกรายงาน
Code (PHP)
<?
header("Content-Type: application/x-msexcel");
header("content-disposition: attachment;filename=Data_bill.xls");
echo "<meta http-equiv='Content-Type' content='text/html; charset=windows-874'>";
?>
ตารางแสดงข้อมูลของผม
Code (PHP)
<td bgcolor="#FFFFFF" ><?
DateThai($strDate2 );
$strDate2 = ($objResult["beforerank"]);
if($strDate2 == "0000-00-00")
{
echo $strDate2 = "";
}
else
{
echo DateThai($strDate2 );
} ?></td>
1.ผมไม่สามารถ ใส่ปีที่นานเกินไปเช่น 2 ก.พ. 2590 แต่ข้อมูลแสดงเป็น 1 ม.ก. 2513
2.ข้อมูลในตารางเช่น 1 ต.ค. 2548 แต่พอ export จะเป็น 1-ต.ค.-46 ซึ่งมีขีด และ ปีไม่แสดงเต็ม
ขอบคุณล่วงหน้าครับ
Tag : PHP, MySQL
|
|
 |
 |
 |
 |
Date :
2013-09-17 17:55:40 |
By :
puldool |
View :
1111 |
Reply :
7 |
|
 |
 |
 |
 |
|
|
|
 |