|
|
|
การคำนวนวันที่อ่ะค่ะ คือ จะเอาโค้ดที่มีการคำนวณวันที่แบบอัตโนมัติอ่ะค่ เช่น เลือกวันเริ่มลาวันที่ 24/04/2552 |
|
|
|
|
|
|
|
ใช้ DateDiff เข้ามาช่วยน่ะครับ
Code (PHP)
<?php
function DateDiff($strDate1,$strDate2)
{
return (strtotime($strDate2) - strtotime($strDate1))/ ( 60 * 60 * 24 ); // 1 day = 60*60*24
}
function TimeDiff($strTime1,$strTime2)
{
return (strtotime($strTime2) - strtotime($strTime1))/ ( 60 * 60 ); // 1 Hour = 60*60
}
function DateTimeDiff($strDateTime1,$strDateTime2)
{
return (strtotime($strDateTime2) - strtotime($strDateTime1))/ ( 60 * 60 ); // 1 Hour = 60*60
}
echo "Date Diff = ".DateDiff("2008-08-01","2008-08-31")."<br>";
echo "Time Diff = ".TimeDiff("00:00","19:00")."<br>";
echo "Date Time Diff = ".DateTimeDiff("2008-08-01 00:00","2008-08-01 19:00")."<br>";
?>
Ref : PHP DateDiff/Time Diff
|
|
|
|
|
Date :
2009-05-05 06:32:02 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Date :
2009-05-05 17:39:52 |
By :
kanowan |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
กำลังหาพอดีเลย
|
|
|
|
|
Date :
2010-10-22 02:07:29 |
By :
SonakO |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
เอาแบบ javascript ไปศึกษาเพิ่มเติมนะครับ
Date Between
var stringToDateObject = function(stringDate) {
var arrString = stringDate.split("/");
return new Date(arrString[1] + "/" + arrString[0] + "/" + arrString[2]);
}
var dateBetween = function(sDate, eDate) {
var startDate = stringToDateObject(sDate);
var endDate = stringToDateObject(eDate);
var oneDay = 24 * 60 * 60 * 1000;
return Math.round(endDate.getTime() - startDate.getTime()) / oneDay;
}
|
|
|
|
|
Date :
2010-10-22 07:34:03 |
By :
DS_Ohm |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 01
|