|
|
|
ผลต่างวันที่ ผมทำฟอร์มเก็บค่าวันที่เป็น TEXT แล้วต้องการหาผลต่างของวันที่ที่เก็บจากฟอร์มกับวันที่ปัจจุบัน |
|
|
|
|
|
|
|
function dateEstime($day,$month,$year){
return mktime(0,0,0,$day,$month,$year);
}
สมมุติค่าที่รับมาจาก form เก็บไว้ในตัวแปรชื่อ $thedate1 มีค่า="05/08/2007";
$thedate=explode('/',$thedate1);
$thedate=dateEstime($thedate[0],$thedate[1],$thedate[2]);
$thisdate=date('d/m/Y');
$thisdate=explode('/',thisdate);
$thisdate=dateEstime($thisdate[0],$thisdate[1],$thisdate[2]);
$day=$thisdate-$thedate;
$day=floor($day/60/60/24);
echo "วันที่ $thedate1 ต่างจากวันนี้ $day วัน";
|
|
|
|
|
Date :
11 ธ.ค. 2550 15:37:53 |
By :
hobbits |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
มันขึ้นข้อความนี้นะครับ
Fatal error: Call to undefined function dateEstime() in D:\AppServ\www\land\sub_detail.php on line 87
|
|
|
|
|
Date :
11 ธ.ค. 2550 15:54:42 |
By :
ji |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Warning: mktime() expects parameter 4 to be long, string given in D:\AppServ\www\land\sub_detail.php on line 88
Warning: mktime() expects parameter 4 to be long, string given in D:\AppServ\www\land\sub_detail.php on line 88
วันที่ ต่างจากวันนี้ 0 วัน
error นะครับ
|
|
|
|
|
Date :
11 ธ.ค. 2550 16:33:34 |
By :
ji |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function dateEstime($day,$month,$year){
return mktime(0,0,0,$day,$month,$year);
}
สมมุติค่าที่รับมาจาก form เก็บไว้ในตัวแปรชื่อ $thedate1 มีค่า="05/08/2007";
$thedate=explode('/',$thedate1);
$thedate=dateEstime($thedate[0],$thedate[1],$thedate[2]);
$thisdate=date('d/m/Y');
$thisdate=explode('/',$thisdate);
$thisdate=dateEstime($thisdate[0],$thisdate[1],$thisdate[2]);
$day=$thisdate-$thedate;
$day=floor($day/60/60/24);
echo "วันที่ $thedate1 ต่างจากวันนี้ $day วัน";
//-- ลืมใส่ $ หน้าตัวแปร
|
|
|
|
|
Date :
11 ธ.ค. 2550 17:08:30 |
By :
hobbits |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function dateEstime($day,$month,$year){
return mktime(0,0,0,$day,$month,$year);
}
//สมมุติค่าที่รับมาจาก form เก็บไว้ในตัวแปรชื่อ $thedate1 มีค่า="05/08/2007";
$thedate=explode('/',$DATERECORD); $DATERECORD ( ชื่อตัวแปรที่ผมเก็บไว้ )
$thedate=dateEstime($thedate[0],$thedate[1],$thedate[2]);
$thisdate=date('d/m/Y');
$thisdate=explode('/',$thisdate);
$thisdate=dateEstime($thisdate[0],$thisdate[1],$thisdate[2]);
$day=$thisdate-$thedate;
$day=floor($day/60/60/24);
echo "<br>วันที่ $DATERECORD ต่างจากวันนี้ $day วัน";
พอทดสอบแล้วตรงผลต่างมันแสดงผลคลาดเคลื่อนนะครับ และถ้าจะใช้ปีเป็น พ.ศ. จะได้ไหมครับ รบกวนอีกทีนะครับ ขอบคุณ
|
|
|
|
|
Date :
12 ธ.ค. 2550 08:51:50 |
By :
ji |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
โทษทีจ้า function ผิด เปลี่ยนเป็นนี่นะ
function dateEstime($day,$month,$year){
return mktime(0,0,0,$month,$day,$year);
}
|
|
|
|
|
Date :
12 ธ.ค. 2550 09:30:33 |
By :
hobbits |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อ้อ ลืม แล้วถ้าจะแปลงวันที่แบบไทย ก็
$DATERECORD="27/12/2550";
$thedate=exlplde('/',$DATERECORD);
$thedate=dateEstime($thedate[0],$thedate[1],$thedate[2]-543);
|
|
|
|
|
Date :
12 ธ.ค. 2550 09:35:38 |
By :
hobbits |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ได้แล้วครับขอบคุณมากกกกกกกกกกกกกกกกกกก ครับ
|
|
|
|
|
Date :
12 ธ.ค. 2550 10:03:43 |
By :
ji |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
gregorianTojd ลองค้นหาดู
|
|
|
|
|
Date :
12 ธ.ค. 2550 11:32:04 |
By :
อิอิ |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
รวบกวนหน่อยนะค่ะเก็บผลการบันทึกรวมกับวันที่ใน engComment
<td colspan="4" bgcolor="#D9E0FF"><span class="style9">ผลการตรวจสอบ</span></td>
</tr>
<tr>
<td colspan="4" bgcolor="#EAF1FF"><?php echo $row['engComment']; ?> </td>
มันจะแสดงประมาณว่า เห็นควรยอมรับ 2009/08/31 มันเก็บความคิดเห็นกับวันที่รวมกันในตาราง ถ้าจะสลับให้เป็น เห็นควรยอมรับ 31/08/2552 ต้องเขียนโค้ตแก้ยังไงอะค่ะเพราะโค้ตที่ใช้ตอนนี้เป็
|
|
|
|
|
Date :
2009-08-31 15:43:25 |
By :
yanana |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|