|
 |
|
ถามเรื่องวันที่หน่อยครับ...สมมุติว่า ผมต้องการไม่ให้โชว์วันที่ก่อนหน้านี้ เช่น วันนี้วันที่ 20 โชว์ 20 - 31 |
|
 |
|
|
 |
 |
|
i=20 ไงครับ
|
 |
 |
 |
 |
Date :
2009-05-20 12:08:48 |
By :
kanchen |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
Code (PHP)
<select name="list_Sdate">
<?php
#รวบรวมค่าต่าง ๆ ที่ต้องใช้ ได้แก่ วัน เดือน ปี ปัจจุบัน
$today=date("d"); $thisMonth=date("m"); $thisYear=date("Y");
#คำนวณว่า เดือนกุมภาพันธ์ของปีนี้มีกี่วัน
$maxDayInFeb =($thisYear%4==0)?29:28;
#กำหนดอาร์เรย์ขึ้นเพื่อเก็บจำนวนวันของแต่ละเดีอน
$maxDay=array(31,$maxDayInFeb,31,30,31,30,31,31,30,31,30,31);
//แสดงผลนับจกวันที่ปัจจุบัน จนถึงวันสุดท้ายของเดือน
for($i=$today;$i<=$maxDay[$thisMonth-1];$i++){
printf("<option value=\"%02d\">%02d</option>",$i,$i);
}
?>
</select>
<hr />
<strong>Because today date is : <?=date("d/m/Y")?></strong>
หวังว่านี่คงช่วยได้นะครับ ^^!
|
 |
 |
 |
 |
Date :
2009-05-20 12:17:22 |
By :
vyper |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
 |
|
|
 |
 |
|
ได้แล้วครับ ขอบคุณครับ
Code (PHP)
<?php
<select name="list_Sdate">
<?php
$today = date("d");
for($i = $today; $i <= 31; $i++)
{ // loop display 1 - 31
if($i < 10)
{
if($today == $i)
{
$temp = $today;
}else{
$temp = "0".$i;
}
}else{
$temp = $i;
} //case one number 1-9 input 0 before
if(date('d') == $temp)
{ // if today number show Default
echo"<option value='$temp' selected='selected'>$temp</option>";
}else{
echo"<option value='$temp'>$temp</option>";
}
}
?>
</select>
?>
|
 |
 |
 |
 |
Date :
2009-05-20 13:58:31 |
By :
คนดำ |
|
 |
 |
 |
 |
|
|
 |
 |
|
 |
 |
|
|
|

|
Load balance : Server 05
|