|
|
|
[PHP] จะเปรียบเทียบเวลา Datetime ยังไงครับว่าเลยมาหรือยัง |
|
|
|
|
|
|
|
ถ้าจะง่าย ๆ น่ะครับ
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>";
if(DateTimeDiff("2010-07-28 18:30","2010-07-28 19:00") > 0 )
{
echo "เลยมาแล้วจ้าาาา";
}
?>
Go to : PHP DateDiff / TimeDiff
|
ประวัติการแก้ไข 2010-07-28 18:48:33
|
|
|
|
Date :
2010-07-28 18:48:10 |
By :
webmaster |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function 3 ตัวบนใช้อันไหนก็ได้ใช่ไหมคับ
|
|
|
|
|
Date :
2010-07-28 18:54:11 |
By :
bosszataroi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
อ๋อเข้าใจละ ขอบคุณมากๆครับ
|
|
|
|
|
Date :
2010-07-28 18:54:51 |
By :
bosszataroi |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Load balance : Server 04
|