|
 |
|
ช่วยด้วยครับพี่ ผมอยากได้ code ที่กำหมดวันที่อ่ะครับ พี่ๆช่วยหน่อยครับ |
|
 |
|
|
 |
 |
|
ผิดครับให้มันแสดงออกมาแบบนี้ครับ
2009/02/26 วันจันทร์
2009/02/27 วันอังคาร
2009/02/28 วันพุธ
2009/03/01 วันพฤหัส
2009/03/02 วันศุกร์
2009/03/03 วันเสาร์
2009/03/04 วันอาทิตย์
2009/03/05 วันจันทร์
2009/03/06 วันอังคาร
แบบนี้ครับ
|
 |
 |
 |
 |
Date :
2009-03-26 18:24:39 |
By :
dr.website |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
strtotime + mktime ผมว่าแค่นี้คุณคงได้ idea แน่นอนชิมิ
|
 |
 |
 |
 |
Date :
2009-03-26 18:46:49 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ผมอาจจะใช้วิธี ลูกทุ่งๆ ไปหน่อยนะครับแต่มันก็ได้ผลลัพธ์ที่ต้องการ ใครมีวิธีอื่น ก็เสนอมาเพื่อให้คนที่อ่านได้ ศึกษากันต่อไปนะครับ
Code
<?php
$date_start = "2009/02/26";
$date_end = "2009/03/06";
$date1=explode("/",$date_start);
$date2=explode("/",$date_end);
$init_date = mktime(12,0,0,$date1[1],$date1[2],$date1[0]); //ว.ด.ป เริ่มต้น
$dst_date = mktime(12,0,0,$date2[1],$date2[2],$date2[0]); //ว.ด.ป สุดท้าย
$offset = $dst_date-$init_date;
$days = floor($offset/60/60/24);
for ($i=0;$i<=$days;$i++) {
$dayok = date("Y-m-d-w", mktime(0, 0, 0,$date1[1],$date1[2] + $i,$date1[0]));
$thai_w=array("อาทิตย์","จันทร์","อังคาร","พุธ","พฤหัสบดี","ศุกร์","เสาร์");
$w=$thai_w[substr ($dayok,11)];
echo substr ($dayok,0,10)."\t";
echo $w."<br>";
}
?>
|
 |
 |
 |
 |
Date :
2009-03-26 19:34:45 |
By :
นักเรียน |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ขอบคุณมากครับผม
ผมจะลองทำดูครับ
|
 |
 |
 |
 |
Date :
2009-03-26 20:07:57 |
By :
dr.website |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
มีคนมาตอบแล้ว ยังไม่ได้ช่วยคิดเลย
Code (PHP)
<?php
$offset = strtotime($date_end) - strtotime($date_start);
?>
ใช้นี่แทน
Code (PHP)
<?php
$date1=explode("/",$date_start);
$date2=explode("/",$date_end);
$init_date = mktime(12,0,0,$date1[1],$date1[2],$date1[0]); //ว.ด.ป เริ่มต้น
$dst_date = mktime(12,0,0,$date2[1],$date2[2],$date2[0]); //ว.ด.ป สุดท้าย
$offset = $dst_date-$init_date;
?>
ก็ได้ครับประหยัดได้หลายบรรทัด แต่คุณ artit_tid เก่งดีนะ ช่วยๆ กันตอบครับ จะได้มีคนเติบโตมาแย่งงานเรา 
|
 |
 |
 |
 |
Date :
2009-03-26 21:41:01 |
By :
plakrim |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
เก่งๆ กันทั้งน้าน ครับเนี้ย ขอบคุณมากครับ
|
 |
 |
 |
 |
Date :
2009-03-26 21:49:59 |
By :
dr.website |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 04
|