 |
|
|
 |
 |
|
นี่ไงครับ...
<?
$today=getdate();
$mday=$today["mday"];
$mon=$today["mon"];
$year=$today["year"];
$year=$year+543;
$thmonth=array("","มกราคม","กุมภาพันธ์","มีนาคม","เมษายน","พฤษภาคม","มิถุนายน","กรกฎาคม","สิงหาคม","กันยายน","ตุลาคม","พฤศจิกายน","ธันวาคม");
echo"<center><font size=5><b>";
$mon=$thmonth["$mon"];
echo "$mday $mon $year";
?>
แต่ผมอยากได้แบบที่เก็บเป็นตัวเลขแล้วมาเป็นภาษาไทยครับ...ช่วยผมที 
|
 |
 |
 |
 |
Date :
19 ธ.ค. 2548 17:00:45 |
By :
chongwut |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ก็ทำเป็นฟังก์ชัน แล้ว รับค่ามีซิครับ
เช่น
function thaidate($today); // รับค่ามาใน รูปแบบ dd/mm/yyyy หรือว่า yyyy/mm/dd ก็ได้
แล้วค่อยมา เลือก string เอา
$mday=$today["mday"]; //ใช้ substr เลือกเอาจาก $today
$mon=$today["mon"]; //ใช้ substr เลือกเอาจาก $today
$year=$today["year"]; //ใช้ substr เลือกเอาจาก $today
จากโค๊กที่คุณให้มาทำแค่นี้ก็น่าจะได้แล้วนะครับ
|
 |
 |
 |
 |
Date :
19 ธ.ค. 2548 17:12:58 |
By :
อั๋น |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณนะคะที่ช่วยเหลือมะนาว 
|
 |
 |
 |
 |
Date :
27 ธ.ค. 2548 15:51:16 |
By :
มะนาว |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
      
|
 |
 |
 |
 |
Date :
2011-02-06 14:21:26 |
By :
.5852 |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
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];
$strYearCut = substr($strYear,2,2); //เอา2ตัวท้ายของปี .พ.ศ.
return "$strDay $strMonthThai $strYearCut";
} //end function DateThai
ลองดูคับ
|
 |
 |
 |
 |
Date :
2011-02-15 11:06:54 |
By :
dbnoon |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
นี่ไงครับอีกอันลองดู
<script language="javascript">
now = new Date();
var thday = new Array ("อาทิตย์","จันทร์",
"อังคาร","พุธ","พฤหัส","ศุกร์","เสาร์");
var thmonth = new Array ("มกราคม","กุมภาพันธ์","มีนาคม",
"เมษายน","พฤษภาคม","มิถุนายน", "กรกฎาคม","สิงหาคม","กันยายน",
"ตุลาคม","พฤศจิกายน","ธันวาคม");
document.write("วัน" + thday[now.getDay()]+ "ที่ "+ now.getDate()+ " " +
thmonth[now.getMonth()]+ " " + (0+now.getYear()+543));
</script>
|
 |
 |
 |
 |
Date :
2012-05-01 20:47:27 |
By :
ruampalung-news.blogspot |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|